I'm having problems when i use the fgets() and the gets() functions.. Code: if(sel==1){ do{ system("cls"); printf("Input a string: "); scanf("%s",&string[s]); s++; do{ system("cls"); printf("String successfully added\n"); printf("Enter another string?\n\n"); printf("1 - Yes\n"); printf("2 - No\n"); scanf("%d",&rep); }while(rep!=1&&rep!=2); }while(rep==1); }
Your code doesn't use fgets or gets. What is the problem? Does string not contain what you expect? Have you RTFM on scanf?
Don't use gets() function, its vulnerable. Code: fgets(string,sizeof(string),stdin); And for scanf(), Code: scanf("%[^\n]",string); Hope that helps you.