I am just a beginning in C and my question is on the topic of strings. I'm studying from a blog who gives the content and then a few questions, one of which is to code a program that reads a string (being specific, a word) and returns which of the letters of the word is repeated. I did the code but when I run it, it returns @@
. Can someone help me or tell me where is the mistake?
code below:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main()
{
char word[11];
int running1;
int running2;
char repeated[11];
printf("Give us a word:");
fgets(word, 11, stdin);
printf("word:%s", word);
for (running1 = 0; running1 < 10; running1++)
for (running2 = 0; running2 < 10; running2++)
if(word[running1] == word[running2])
{
word[running1] = repeated;
}
printf("\nletters repeated:%s", repeated);
}