The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #2 (permalink)  
Old 03-06-2008
shamrock shamrock is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2007
Location: USA
Posts: 741
Quote:
Originally Posted by ramkrix View Post

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.