For one or two repeated names, it works fine, but if I make them all the same it repeats about ten times. I already tried to use flag, but I can not understand the reasoning.
#include <stdio.h>
#include <stdlib.h>
/*
Lucas Correia, 2018
*/
int main(int argc, char *argv[]) {
char nomes[5][50];
int i=0, j=0, flag = 0;
for(i=0; i < 5; i++){
printf("Informe o nome:");
scanf(" %[^\n]s", nomes[i]);
}
for(i=0; i < 5; i++){
for(j = i+ 1; j < 5; j++){
if(stricmp(nomes[i], nomes[j])==0){
printf("\nRepetead: %s", nomes[i]);
flag = 1;
if(!flag){
break;
}
}
}
}
return 0;
}