C Reference Space, formfeed, newline, etc test: isspace()
The isspace() function returns a non-zero if its argument is a single space, newline, tab, form feed, vertical tab, or carriage return.
If the argument is not a single space, newline, tab, form feed, vertical tab, or carriage return , then zero is returned.
isspace() source code example:
#include<stdio.h>
#include<ctype.h>
int main()
{
int newchar;
int counter=0;
char str[]="Testing the isspace function\n";
while (str[counter])
{
newchar=str[counter];
if (isspace(newchar)) newchar='#';
putchar (newchar);
counter++;
}
return 0;
}
Note: every space, newline, tab, form feed, vertical tab, or carriage return in the sentence is replaced with a #.
This entry was posted in C Reference ctype.h Functions.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
Tweet This! or use
to share this post with others.