Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

c

What is iswspace in C?

Hammad Nasir

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The iswspace function

iswspace is a function in C and is defined as follows:

int iswspace( wint_t ch );

The function iswspace returns a non-zero value if the argument ch is a wide character; otherwise, it returns 0. The function is part of the wctype.h library.

Here, the wide character is a white space character which can be any one of the following:

Wide Character Escape Sequence
Space
Form Feed \f
Line Feed \n
Carriage Return \r
Horizontal Tab \t
Vertical Tab \v

Note: Wide space character representation in other locales will also result in a non-zero return value.

Example usage of the iswspace function

The following code snippet demonstrates how to use the iswspace function:

#include<stdio.h>
#include <wchar.h>
#include <wctype.h>
int main() {
wchar_t space = ' ';
wchar_t horizontal_tab = '\t';
wchar_t a = 'a';
printf("Space: %d\n", iswspace(space));
printf("Horizontal Tab: %d\n", iswspace(horizontal_tab));
printf("A: %d", iswspace(a));
return 0;
}

In the example above, the result of passing both space and horizontal_tab as arguments to iswspace function is 8192. Meanwhile, in the case of a, the result is 0.

Note: A non-zero return value for the iswspace function implies a 0 return value for the iswalnum, iswgraph, and iswpunct functions.

RELATED TAGS

c

CONTRIBUTOR

Hammad Nasir
Copyright ©2022 Educative, Inc. All rights reserved

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring