I've been having a little problem with grabbing a word from a file then checking it using an if statement to see if it is true or not.
when the code reaches the "printf("Line = ...." it prints out the variable, which is the first string then the second string, but when the if statement comes in, even though it the exact same that it is in the data file, it turns out to be false and doesn't execute.
this is the concept code:
Code:
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE * in = fopen("DATA.txt", "r");
char line[255];
if (in == NULL)
{
printf("The input file was not found, or an error occured while reading the file");
return 1;
}
else
{
while (!feof(in))
{
fscanf(in, "%s", line);
printf("Line = %s\r\n", line); /* this was here to debug */
if (line == "Test:")
{
fscanf(in, "%s", line);
if(line == "True")
{
printf("This is a test");
getchar();
}
else
{
printf("This is not a test");
getchar();
}
}
}
}
return 0;
}
and the data file is