I tried to look for my problem all over stackoverflow, and found nothing similar. I am working an an assignment that requires me to go through each argument, and if it is a text file, to output the textfile's length for each argument given.
The main part of the function I have no trouble with. The only problem I have is that we have to have certain flag (denoted as '-c'), which if the flag was in the argument, it would change the behavior of the main program. For instance, '-c' would just output the contents of the textfiles instead of printing out it's length.
I understand that they way to go by this using boolean values, seeing if the flag is in the argument or not. However, no matter what method I try, my compiler keeps coming up with this mysterious expected unqualified id.
My code begins with
int main(int argc, char *argv[]){
for ( i = 1; 1 < argc; i++) // iterating through each textfiles
}
I want the program to see if argv[i] is the flag that I defined, but whatever method I try to implement the flag, I always get this error.
bool isflag (string -c)
or
bool -c;
-c = true;
if (isflag){
...
}
And none of these work. I assume it has something to do with the dash character. I'm just really in a hunch and I have no idea what to do to solve this.