Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Borland C++ 2.x ( with Turbo C ) - <b>isspace() test for white-space character (macro)</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
 isspace()               Test for White-Space Character (Macro)

 #include   <ctype.h>

 int        isspace(c);
 int        c;                           Integer value to be tested

    isspace() tests whether 'c' is a white-space character; that is, a
    space, a horizontal or vertical tab, a new-line character, a
    form-feed character, or a carriage-return.

       Returns:     Nonzero if the test is true and zero if it is false.
                    The result is undefined if 'c' is not 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))) {
                             putchar('\n');
                             x = 0;
                      }
                      else
                          putchar(ch);
                  fclose(stream);
               }
           }



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

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