Problem with char and char*
I have got a lot of errors from the line which has the 3 if statements in it.
Code:
C:\WINDOWS\Desktop\code.c(21): error #2168: Operands of == have illegal types 'char' and 'char *'.
C:\WINDOWS\Desktop\code.c(21): error #2157: Unrecognized statement.
C:\WINDOWS\Desktop\code.c(21): error #2001: Syntax error; found 'if' expecting ';'.
C:\WINDOWS\Desktop\code.c(21): error #2168: Operands of == have illegal types 'char' and 'char *'.
C:\WINDOWS\Desktop\code.c(21): error #2157: Unrecognized statement.
C:\WINDOWS\Desktop\code.c(21): error #2001: Syntax error; found 'if' expecting ';'.
C:\WINDOWS\Desktop\code.c(21): error #2168: Operands of == have illegal types 'char' and 'char *'.
C:\WINDOWS\Desktop\code.c(47): warning #2096: Missing return value.
C:\WINDOWS\Desktop\code.c(47): error #2001: Syntax error; found 'end of input' expecting '}'.
C:\WINDOWS\Desktop\code.c(21): error #2168: Operands of == have illegal types 'char' and 'char *'.
C:\WINDOWS\Desktop\code.c(21): error #2157: Unrecognized statement.
C:\WINDOWS\Desktop\code.c(21): error #2001: Syntax error; found 'if' expecting ';'.
C:\WINDOWS\Desktop\code.c(21): error #2168: Operands of == have illegal types 'char' and 'char *'.
C:\WINDOWS\Desktop\code.c(21): error #2157: Unrecognized statement.
C:\WINDOWS\Desktop\code.c(21): error #2001: Syntax error; found 'if' expecting ';'.
C:\WINDOWS\Desktop\code.c(21): error #2168: Operands of == have illegal types 'char' and 'char *'.
C:\WINDOWS\Desktop\code.c(47): warning #2096: Missing return value.
C:\WINDOWS\Desktop\code.c(47): error #2001: Syntax error; found 'end of input' expecting '}'.
How do I make the two types compatible with eachother so that the Operands of illegal types.... message goes away?
Code:
#include <stdio.h>
int main()
{
FILE *f;
char s[1000];
f=fopen("file.txt","r");
if (!f)
return 1;
while (fgets(s,1000,f)!=NULL)
{
printf("Test");
printf("%s",s);
if (s[1] == "N") && if (s[2] == "O") && if (s[3] == "P") {
if (s[4] == 0) {
printf("00 00 00 00 // NOP");
} else {
printf("Syntax error. NOP should not have anything else after it");
}
}
fclose(f);
return 0;
}