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

Shilpa1's Avatar, Join Date: Nov 2007
Go4Expert Member
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.
technosavvy's Avatar
if u r reading the file character by character..ignore the character read whenever there is a space 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...