isspace() Test for White-Space Character
#include <ctype.h>
int isspace(c);
int c; Integer value to be tested
isspace() tests if 'c' is a white-space character; that is, a
horizontal tab, a new-line, a vertical tab, a form-feed, a
carriage-return or a space.
Returns: True (nonzero) if the integer satisfies the test
condition or false (zero) if it does not. The result is
undefined if 'c' is other than an ASCII character or EOF.
Notes: isspace() is a macro.
-------------------------------- Example ---------------------------------
The following statements read characters from a file and put each
word (characters set off by a space) on a separate line.
#include <ctype.h>
#include <stdio.h>
FILE *stream;
int ch;
int x = 0;
main()
{
if ((stream = fopen("data.txt","r+")) != NULL) {
while (!feof(stream))
if(isspace(ch = getc(stream))) {
fputchar('\n');
x = 0;
}
else
fputchar(ch);
}
}
Seealso:
This page last updated on Fri Nov 30 10:48:32 MSK 2001
Copyright © 1992-2001, Vitaly Filatov, Moscow, Russia
Webmaster