C++ | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

C++

Im new here guys pls help me. I would like to make a program that if you input characters it would I dentify those characters individually if its an alphabet, number and special character. And have counters and stuff. How would I start?

14th May 2019, 4:33 AM
Aivan Ace
Aivan Ace - avatar
3 Answers
+ 4
Include <cctype> header file, then you can use: ● std::isalpha to check whether a char was alphabetical ● std::isdigit to check whether a char was numerical There are other functions defined in that header you might find suitable to check for special characters (you didn't specify what they are). In your code you need to setup some counter variables whose value are to be incremented when a character fits a criteria (alphabet, numeric etc). When a character was alphabetical increase variable counter for alphabets, when it's a number increase counter variable for numbers, etc. For reference: http://www.cplusplus.com/reference/cctype/ Hth, cmiiw
14th May 2019, 5:02 AM
Ipang
+ 4
Thank you so much guys for the quick feedback. I really appreciate it.
14th May 2019, 5:06 AM
Aivan Ace
Aivan Ace - avatar