Quote:
Originally Posted by ramkrix
My Question Now:
1. in the program, I used a While loop with an varaible "X" and comparing it to random no of my choice 5 . Instead I want to check the EOF condition in the whilepart. How to check that.
If we are using file pointer and fopen fn, we can use while(feof(fp)==0). But here we used syatem calls and I don know how to check the condition here.
2. In te program output, I found "FIVE" before printing the filedescriptor number. But as per my program flow, fd should be printed first and then the output "FIVE".
3.Is there any othet way of writing the program more simple and precise, especially using piointer for getting the name of the file, instaed of using Array.
Please Help...
Thanks,
Ramkrix
|
Code:
#include <stdio.h>
main(int argc, char *argv[])
{
char *infile;
FILE *stream;
infile = argv[1];
stream = fopen(infile, "r");
}
...now you can use the stream status functions like feof or ferror.