C++ Locale Library - isspace



Description

It checks if character is a white-space and other locales may consider a different selection of characters as white-spaces, but never a character that returns true for isalnum.

Declaration

Following is the declaration for std::isspace.

C++98

int isspace ( int c );

C++11

int isspace ( int c );

Parameters

c − Character to be checked, casted to an int, or EOF.

Return Value

It returns a value different from zero.

Exceptions

No-throw guarantee − this function never throws exceptions.

Example

In below example for std::isspace.

#include <stdio.h>
#include <ctype.h>
int main () {
   char c;
   int i=0;
   char str[]="tutorials point india pvt ltd\n";
   while (str[i]) {
      c=str[i];
      if (isspace(c)) c='\n';
      putchar (c);
      i++;
   }
   return 0;
}

The sample output should be like this −

tutorials
point
india
pvt
ltd
locale.htm
Advertisements