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 12 years, 4 months ago.

  • Author
  • #1984


    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

You must be logged in to reply to this topic.