Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Blank Line from File Input

Status
Not open for further replies.

garishnikov

Programmer
Mar 20, 2003
6
AU
Hi

Could anyone tell me how to test for a blank line. I have the following but it obviously doesnt work:

if(*rawLine != NULL)
{
/* do stuff */
}

where i have the declaration:

char *rawLine;

which points to a string.

I simply want to ignore blank lines.
 
What is it a blank line (C-string)? If it's zero length string, test:
Code:
if (!rawLine || !*rawLine)
/* then it's null pointer or empty string */
If a blank line is a line with blanks or tabs only (or empty string), test:
Code:
if (!rawLine || !*rawLine 
|| strspn(rawLine," \t") == strlen(rawLine))
/* then it's null ptr, empty string or line with whitespaces */
ANSI/ISO Std RTL strspn() functions lives in <string.h>...
 
for(i = 0, rawLine, i++)
{
if(isspace(rawLine)return line is not blank...
}
return line is blank...

Ion Filipski
1c.bmp
 
again:
for(i = 0, rawLine, i++)
{
if(!isspace(rawLine)return line is not blank...
}
return line is blank...


Ion Filipski
1c.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top