Code:
#include<stdio.h>
#include<string.h>
int main()
{
char word[100], temp[] = {'temp'};
int i=0, k=0, count=1;
printf("Enter string: ");
scanf("%s",word);
printf("You entered: %s\n",word);
printf("The length of your string is: %d characters\n", strlen(word));
for(i=0; i<strlen(word);i++)
{
//printf("I before loop is : %d\n",i);
for (k=i+1;k<=strlen(word);k++)
{
//printf("I in loop is : %d\n:",i);
//printf("K in loop is : %d\n", k);
if(word[i] == word[k])
{
printf("value of k: %d (letter)\n",i);
printf("value of i: %d (compareTo)\n",k);
count++;
}
printf("count is: %d\n",count);
printf("2nd value of i: %d (letter)\n",i);
printf("2nd value of k: %d (compareTo)\n",k);
//printf("Character : %c occurs: 1 time.\n", word[i]);
}
printf("3rd value of i: %d (letter)\n",i);
printf("3rd value of k: %d (compareTo)\n",k);
count =1;
//printf("character being looked at 3 is %c\n",word [i]);
}
return 0;
}