Hi all, I'm new here. My intent is to get this function to return an integer which I can use in a subsequent switch statement. Somehow, it does not work, and I have a strong inkling that I used if-statements in a bad way.
As you can most likely guess, this is neither the entire project nor the complete file.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
int verifyMult105(char *buffer, long linecount){ //not finished!!
char *strTime = NULL;
char *strNumb = NULL;
char *strVers = NULL;
if ((strTime = strstr(buffer, "Uhrzeit") != NULL)){
return 1;
}
if ((strNumb = strstr(buffer, "Zugummer") != NULL)){
return 2;
}
if ((strVers = strstr(buffer, "Version") != NULL)){
return 3;
}
else {
printf("Warnung: Falscher Wert in Zeile: %d\n", linecount);
};
}
I also get compiler warnings for every if-statement, namely [Warning] assignment makes pointer from integer without a cast
Argh, I somehow completely forgot about else if. Sadly, it didn't get rid of the warnings :(
I wonder if I'm using the strstr() function correctly, but I don't know what I'm doing wrong, because the project compiles and runs, but this function just refuses to work (well, the error msg in the else-statement works). I know for sure the string buffer contains the correct data, and linecount does, too. The funny thing is, the line returned to the console is always -1.