|
||||||
| C and C++ C and C++ forum for discussing all forms of C except for C#. These languages are powerful low level languages used for creating Operating Systems, Device Drivers, compilers and much more. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
| Sponsored Links |
|
|
|
|||||
|
I've made a version of mine. Take a look at it.
I think you've been confused with the array. Code:
#include <stdio.h>
int main()
{
int Text[26] = {0};
int TextInput = 0;
int AsciiCount = 0;
int Alpha = 0;
printf("\nPlease enter text. Terminate program using Ctrl+Z: ");
do
{
Alpha = 1;
TextInput = getchar();
if(TextInput >= 'a' && TextInput <= 'z')
TextInput -= 'a';
else if(TextInput >= 'A' && TextInput <= 'Z')
TextInput -= 'A';
else
Alpha = 0;
if(Alpha)
Text[TextInput]++;
} while(TextInput != EOF);
for(AsciiCount = 0; AsciiCount <= 25; AsciiCount++)
printf("\nTotal %c or %c: %d", AsciiCount + 'A', AsciiCount + 'a', Text[AsciiCount]);
return 0;
}
This is the output: Code:
Please enter text. Terminate program using Ctrl+Z: www.codecall.net Total A or a: 1 Total B or b: 0 Total C or c: 2 Total D or d: 1 Total E or e: 2 Total F or f: 0 Total G or g: 0 Total H or h: 0 Total I or i: 0 Total J or j: 0 Total K or k: 0 Total L or l: 2 Total M or m: 0 Total N or n: 1 Total O or o: 1 Total P or p: 0 Total Q or q: 0 Total R or r: 0 Total S or s: 0 Total T or t: 1 Total U or u: 0 Total V or v: 0 Total W or w: 3 Total X or x: 0 Total Y or y: 0 Total Z or z: 0
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum C/C++ resources - C/C++ frequently asked questions Python resources - Python frequently asked questions I'm always up for a chat, so feel free to contact me... |
|
|||||
|
That helped solve the problem for me. Thanks V0id!
![]() I never thought to use the actual input within the while loop. I always ***umed that I would need to put in the input first and then execute the loop where each character is read individually while the input is not at the end of the file. I also thought that I would need to execute the ASCII count by listing the letters by their ASCII numbers rather than go from 0 to 25. Guess that didn't work. ![]()
__________________
For $1000: Something that is a miserable pile of secrets. |
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to style fonts of a text in a simple page? | c0de | Tutorials | 3 | 09-15-2007 10:08 PM |
| Xav | ........ | 1322.18 |
| MeTh0Dz|Reb0rn | ........ | 1053.7 |
| morefood2001 | ........ | 879.43 |
| John | ........ | 877.37 |
| marwex89 | ........ | 869.98 |
| WingedPanther | ........ | 830.24 |
| Brandon W | ........ | 735.07 |
| chili5 | ........ | 309.39 |
| Steve.L | ........ | 239.84 |
| dcs | ........ | 216.02 |
Goal: 100,000 Posts
Complete: 82%