I declare
char pl1[10], pl2[10];
And I did the following:
printf("Nome do Player1: ");
scanf("%10s", &pl1);
printf("Nome do Player2: ");
scanf("%10s", &pl2);
Thinking he would read only the first 10 characters that the user types. So, when I type a name with more than 10 characters the program reads wrong, for example, it is typed "dynamically", it associates "dynamicame" with pl1
and "nte" with pl2
. I have tried it also without the 10 in the scanf
it stores what exceeded the scope in pl1
, example (using "dynamically") it ignores the first name entered (if the second is longer than 10 characters), and assign the first 10 characters typed when you ask for Nome do Player 2
a pl2
and the rest on pl1
. If the typed in pl2
is less than 10 characters it stores it dynamically in pl1
and the name that was typed in pl2
.