So I am still a noob at c programming and I need help making my main function to run while not having any if or for statements. It can only declare variables and functions.
Since my main function has command line arguments, I am confused on how to so.


// This program counts all the words in a given file. #include #include #include int main(int argc, char* argv&#91;&#93;){ FILE* txtFile = NULL; // File Pointer char str&#91;1000000&#93;; int count = 0, i, len, ignoreSpace; // Variabales // Assigns the text file to txtFile txtFile = fopen(argv&#91;1&#93;, "r"); // Gives error if myfile.txt is not located if (txtFile == NULL) { printf("Error opening file&#092;n"); // Couldnt find .txt file return -1; // -1 indicates error } // Can use fgets(inFile, ...) like scanf() while(fgets(str, 1000000, txtFile)) // EX: str = "THIS IS A LINE" { len = strlen(str); ignoreSpace = 1; for (i = 0; i < len; i++) { if (str&#91;i&#93; == ' ') { if (!ignoreSpace) { count++; ignoreSpace = 1; } } else { ignoreSpace = 0; } } if (!ignoreSpace) count++; } printf("There are %d word(s).&#092;n", count); fclose(txtFile); return 0;}

More...