My program:
Code:
int main()
{
char string[100];
int i=0, j=0, NoLetter[25];
clrscr();
printf("Enter string: ");
scanf("%s", string);
do
{
for (j=97; j<=122; j++)
{
if (string[i] == j)
{
NoLetter[j-97]++;
printf("\nString contains %d \"%c\"", NoLetter[j-97], string[i]);
}
}
} while (string[i++] != '\0');
getch();
return 0;
}
The problem is the output:
Enter string: hello
String contains 1 "h"
String contains 1 "e"
String contains 1 "l" <- this I do not want to print it on the screen
String contains 2 "l"
String contains 1 "o"
I know that this prints out beacuse it is in the loop. I tried various ways, but none worked out.
Please help.