I am a beginner at C and am using DevC++. I have written the code below and wish to read in the data written in input.txt. However when I try to run the code, I always receive the "Cant open file" message. It seems unable to find input.txt, and I am entirely unsure how to change that.
int T;
char command;
FILE *inputfile;
inputfile = fopen("input.txt", "r");
if(inputfile == NULL)
{
printf("Cant open file");
}
fscanf(inputfile, "%d", &T);
It can be because of the following reasons
Otherwise your code is correct there should be no problem
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.