Read all the lines from a file

Home Forums C Programming Read all the lines from a file

This topic contains 0 replies, has 1 voice, and was last updated by  rana_sandeep 11 years, 5 months ago.

  • Author
    Posts
  • #1984

    rana_sandeep
    Member

    Hello Team,

    I want read all the lines from a file using c program using command line arguments. I tried using “fscanf”. I want to eliminate the line start from ‘#’.
    But fscanf is reading all the words. Then I tried using fgets and sscanf. But sscanf is reading only first word of a line. How do read all the from a file and each word in a line should take is as separate array.

    Ex: I am vasu.
    Line:I am vasu
    I need output like this:
    array 1: I
    array 2 : am
    arry 3 : vasu

    If the line start from # I want ignore that line.

    Any inputs are highly appreciate

    Thanks in advance
    Vasu.

You must be logged in to reply to this topic.

Share
Tweet
Share
Pin
+1