I'm trying to write a program where the user has to write two different strings, but after the first string is entered the program ends. This is the code:
int i=0, N=100;
char car, v1[N+1], v2[N+1];
printf("Insert the first string: \n");
while ((car=getchar())!=EOF) {
v1[i]=car;
i++;
}
i=0;
printf("Insert the second string: \n");
while ((car=getchar())!=EOF) {
v2[i]=car;
i++;
}
In theory after the first string is written and I press CTRL-D (on Mac, it's the same as CTRL-Z) it should print the "Insert the second string" and allow me to write it.
What actually happens is that I have to press CTRL-D again (because it doesn't output the second printf), at that point the program ends, and it outputs (after the first string I wrote) "Insert the second string", but I cannot write it!
Can you help me please?