I am writing a code and I need to use a loop. I am reading data from a file (data.txt) that looks like this:
IMPORT 450
EXPORT 200
IMPORT 100
and so on.
Here is the segment of the code that I am having trouble with
inputfile = fopen("c:\\class\\data.txt","r");
fscanf(inputfile,"%s %f", &transaction, &amount);
do{
total += amount;
printf("Data %s %f %f\n", transaction, amount, total);
fscanf(inputfile, "%s", &transaction);
}while (transaction == "IMPORT" || transaction == "EXPORT");
When I add a printf line to check what 'transaction' is it shows IMPORT, so I am not sure why the do-while loop is not repeating.
Thank you!