i need to Design and write a program to count the number of occurrences of each of the characters ‘A’ to ‘Z’, ‘a’ to ‘z’ and ‘0’ to ‘9 entered through stdin.
i was thinking of defining a struc for char lower char upper and int digit
but then how do i count this
am really confused any help would be great
JOHN-shirley
0
Newbie Poster
Recommended Answers
Jump to PostI would do it by using an array of 255 ints, each element in the array represents one of the characters in standard ascii character set. So, if you enter 'A', then all you have to do is increment array['A']++. When done, all the non-zero elements are what you want. …
Jump to PostThey are all really chars.
There really is no such thing as a char in C and C++ languages, the data type char is just a one-byte integer with a range of values from 0 to 255 (unsigned) or -127 to 127 (signed). The compiler treats 'A' as …
Jump to PostIt depends how you interpret the OPs original question.
I'd interpret it in the same way as ddanbe. Rather than wanting to count each occurrence of each individual character in those ranges, the OP wants to count the following:
- The number of numeric digit characters
- The number of …
All 9 Replies
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
iamthwee
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
ddanbe
2,724
Professional Procrastinator
Featured Poster
David W
131
Practically a Posting Shark
Ancient Dragon
5,243
Achieved Level 70
Team Colleague
Featured Poster
JasonHippy
739
Practically a Master Poster
JOHN-shirley
0
Newbie Poster
David W
131
Practically a Posting Shark
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.