How to remove blank spaces and comments while reading data from a file in C?

Discussion in 'C' started by Shilpa1, Apr 11, 2008.

  1. Shilpa1

    Shilpa1 New Member

    Joined:
    Nov 8, 2007
    Messages:
    13
    Likes Received:
    0
    Trophy Points:
    0
    Hai,
    I want to read data from file and print the contents of the file.While reading it must ignore the blank lines and comment lines.How to do this?Pls help me.
     
  2. technosavvy

    technosavvy New Member

    Joined:
    Jan 2, 2008
    Messages:
    52
    Likes Received:
    0
    Trophy Points:
    0
    if u r reading the file character by character..ignore the character read whenever there is a space ...tab...newline..or any other white space ...

    and if u store the contents in a buffer then traverse the buffer and remove whitespace before printing it ..

    to remove comments u should know what a comment in your file looks like..
    can a comment be multi-line comment or will it be a single line comment...
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice