How to read special data on text file?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • helios
    New Member
    • Sep 2008
    • 2

    How to read special data on text file?

    hi all,
    I have a text file follows and it is a content:

    2
    D:\MessageLog.t xt
    D:\CVK.mp3
    D:\Encode\
    2
    D:\Decode\


    How to read one first line save name variable (n=2) and after that is perform
    for(int i=0; i<n; i++)
    //read second line to line n
    //save to arrays: arrayfile[n]
    The end, inspecting array "arrayfile" read information on file by file and show data on console screen. Thank everybody so much.
  • gpraghuram
    Recognized Expert Top Contributor
    • Mar 2007
    • 1275

    #2
    Use fscanf to read the first line(That is the number).
    Have a for or while loop to read that many number of lines using fgets.

    Raghu

    Comment

    Working...