hi - i have a problem using strings in text output.
when i put the following code in my 'play'-function,
[...]
char name[20]; /* at top of the function */
printf("\n Hello! What is your name? > ");
scanf("%s",&name[0]);
printf("\n Ok, %s, let's get it on...\n\n",name);
[...]
then the program is running until you enter
a name like "Peter Pan" with a space inside.
Now the program would run once displaying
"Ok, Peter, ..." and after that (without
entering the 'again'-question) it runs with
"Ok, Pan, ...". and this way i don't want
to include this code in my program.
when i try this:
[...]
char name[20]; /* at top of the function */
printf("\n Hello! What is your name? > ");
gets(name);
printf("\n Ok, %s, let's get it on...\n\n",name);
[...]
the program is not working. it runs, but you won't
be able to enter your name. the program just displays
the text out of 'printf' and just puts a space instead
of the %s data.
can someone explain why this happens?
at last i tried this:
[...]
char name[20]; /* at top of the function */
printf("\n Hello! What is your name? > ");
gets(name);
printf("\n Ok, ");
puts(name);
printf(", let's get it on...\n\n");
[...]
but puts can't display anything, when gets won't work.
thanks for any help!