Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

c

What is iswcntrl() in C?

Syed Muhammad Ali Mustafa

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 iswcntrl() function checks whether the wide character passed to it as an argument is a control character or not.

ASCII values in hexadecimal of control characters

Library

#include<wctype.h>

Declaration

Following is the declaration of iswcntrl() in C, where c is the character to be checked:

int iswcntrl(wint_t c);

Return value

The function returns an integer value.

If the integer returned is non-zero (true), it means c is a control character.

If the integer returned is zero (false), it means c is not a control character.

Code

#include <wctype.h>
#include <wchar.h>
int main()
{
//first 3 characters are control characters
wchar_t ch[] = {0x12, 0x00, 0x7F, 0x20, 0x7E, 0x33};
int i = 0;
while (i < 6) {
if(iswcntrl(ch[i]))
wprintf (L"Control character.\n");
else
wprintf(L"Not a control character.\n");
++i;
}
return 0;
}

RELATED TAGS

c

CONTRIBUTOR

Syed Muhammad Ali Mustafa
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