Hey all.
I'm fairly new to programming and I just have a little issue. I have a code that will read in a string of character and outut weather the character are alphabetical or not but i also need to use a counter to count how many time each character is used.
For example:
Hi my name is Jon.
would out put
h = 1
i = 2
m = 2 etc.
any help would be great.
#include <stdio.h>
#include <string.h>
#include <ctype.h>
void readin(char line[])
{
printf("Enter string: ");
scanf("%s", line);
strlen(line);
return;
}
void counter(char line[], int &count)
{
while(line[count])
{
if(isalpha(line[count]))
printf("Character %c is alphabetic\n",line[count]);
else
printf("character %c is not alphabetic\n",line[count]);
count++;
}
return;
}
int main()
{
const int MAXSIZE = 100;
char line[MAXSIZE] = {'\0'};
int count;
count = 0;
readin(line);
counter(line,count);
return(0);
}