Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,870 questions

51,793 answers

573 users

How to check whether or not each character in a wide string is alphanumeric in C

1 Answer

0 votes
#include <stdio.h>
#include <wchar.h>

int main(void)
{
    wchar_t str[] = L"C 17 Programming!";

    int i = 0;
    while (str[i]) {
        if (iswalnum(str[i])) 
            wprintf(L"%lc is an alphanumeric\n", str[i]);
        else  
            wprintf(L"%lc is not an alphanumeric\n", str[i]);
        i++;
    }

    return 0;
}





/*
run:

C is an alphanumeric
  is not an alphanumeric
1 is an alphanumeric
7 is an alphanumeric
  is not an alphanumeric
P is an alphanumeric
r is an alphanumeric
o is an alphanumeric
g is an alphanumeric
r is an alphanumeric
a is an alphanumeric
m is an alphanumeric
m is an alphanumeric
i is an alphanumeric
n is an alphanumeric
g is an alphanumeric
! is not an alphanumeric

*/

 



answered Jul 31, 2022 by avibootz

Related questions

1 answer 165 views
3 answers 222 views
1 answer 135 views
1 answer 125 views
2 answers 165 views
2 answers 189 views
...