Exforsys
+ Reply to Thread
Results 1 to 3 of 3

What commands are available

This is a discussion on What commands are available within the C and C++ forums, part of the Programming Talk category; What are the commands that are available to read text files in C programming language? If someone could give me ...

  1. #1
    Rahulbatra is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    124

    What commands are available

    What are the commands that are available to read text files in C programming language? If someone could give me the usage of these commands also I could get a detailed idea on the same.


  2. #2
    norman is offline Member Array
    Join Date
    May 2006
    Answers
    43
    Have a file pointer and open the file using fopen in read mode denoted by r+. Check and exit if file pointer is equal to NULL since it means file not found. If file pointer not equal to NULL then read the file using fgets function.

    Try the above logic and let me know if you get struck. I will help you out.


  3. #3
    Sandhya.Kishannag is offline Member Array
    Join Date
    Feb 2012
    Answers
    66
    fopen is used open a text file for reading.
    The file is opened for reading. Each line is successively fetched using fgets command. The string is then converted to a long integer. fgets returns NULL when there are no more lines in the file.


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...