Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Microsoft C - <b>isspace() test for white-space character</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
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);
              }
          }

See Also: isalnum() isalpha() isascii() isdigit() isgraph()

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson