-
program freezing
I've been trying to implement the strcmp method, but the following code causes my program to freeze - most specifically, i've narrow it down to the line in bold.
Code:
for(ii = 0; ii < stackSize; ii++) {
fgets(aa[ii], LINE_SZ, stdin);
if(strcmp(aa[ii][0], "<") != 0) {
printf("Bad input.\n");
ii--;
}
}
How do I properly implement strcmp? I'm trying to see if the first character of each input line is "<" or not.
-
If it's the first character, it's not a string is it? Either use strncmp() or:
Code:
if(aa[ii][0] == '<')
{
-