
Beginner question - printf and scanf
Quote:
> I am getting input from the user with scanf - and I don't want to limit the
> number of characters he/she is inputting, ie, I am allowing up to 15
> characters. Then I want to put that data in a printf statement *but* only
> send to the screen the first character that the user inputted... how the
> heck would I do that?
Don't use scanf() for user input, if the input isn't what you expect,
you can get into serious trouble. It's better to use fgets():
char buffer[40]; /* let's be generous */
if(fgets(buffer, sizeof buffer, stdin) != NULL)
{
putchar(buffer[0]);
/* or: */
printf("%c", buffer[0]);
Quote:
}
Gergo
--
Heisenberg might have been here.