Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

c

What is iswalnum() 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 iswalnum() function checks whether or not the given wide character is an alphanumeric characteruppercase/lowercase letter or decimal digits.

Alphanumeric characters

Library

#include <wctype.h>

Syntax

The function prototype is as follows:

int iswalnum(wint_t ch);

ch: wide character to be checked.

Return Value

The function returns an integer value:

  • If the integer returned is non-zero (true), it means ch is a letter or a digit.
  • If the integer returned is zero (false), it means ch is not a letter or a digit.

Code

#include <stdio.h>
#include <stddef.h>
#include <wctype.h>
#include <wchar.h>

int main ()
{
  int i=0;
  wchar_t str[] = L"Earth_123!";
  while (str[i])
  {
    if (iswalnum(str[i])) //if a letter or a digit, non-zero(true) value is returned
      wprintf (L"%lc is an alphanumeric character\n", str[i]);
    else  //not a letter and not a digit
      wprintf (L"%lc is not an alphanumeric character\n", str[i]);
    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