what I'm trying to do is create a loop that collects a string (in this case a name) and then questions the user through the request of a character whether he wants to keep inserting more.
#include <stdio.h>
#include <string.h>
void main(){
char c, str[5][20];
int i=0;
do {
printf("What's your name?\n");
gets(str[i]);
i++;
printf("Do you want to insert more?\n");
scanf("%c\n",&c);
} while (c=='y');
}
The number of strings that I read and their lenght are arbitrary and not what I'm having trouble with, was just wondering if there was a "correct way" of using this kind of acquisition or if I should give up on it.
This becomes easier, when turning it around: instead of asking for more, wait for empty input