Reputation: 5685
I want to read a txt file line by line. I am getting the error"the device is not ready". I can't understand what the problem is? The code is as follows:
#include<stdio.h>
#include<stdlib.h>
int main(int argc, char **argv)
{
char command[100];
char line[10];
FILE* fp = fopen("input.txt","r");
while (fgets(line, sizeof line, fp) != NULL)
{
puts(line);
}
getchar();
return 0;
}
Can anybody tell me what mistake I am doing? Thanks in advance. operating sys : windows 7; compiler : dev c++
Upvotes: 1
Views: 706
Reputation: 1
Your code works fine on my computer. So the error may come from your hardware or other related stuff...
My system is Redhat and the compiler is gcc 3.4.6!
Upvotes: 0
Reputation: 20706
assert()
that fp
is not NULL
)Upvotes: 2