-
reading off characters
hi i want to ask how to read off characters into display. here is my code:
Code:
#include <stdio.h>
int main()
{
char name;
printf("Please enter your name: ")
scanf("%c", &name);
printf("%c loves lenovo thinkpads.", name);
return 0;
}
everytime i press run the followong result appears:
Code:
Please ente your name: amie
a loves lenovo thinkpads.
i don't know why the first character only appears.
-
A single char can only hold 1 char.
You need an array of them to store a whole word.
And change your %c formats to %s (read about them).
-
Hey Salem, you know what would be cool? If someone would sit down and write a tutorial about this and, wait brainstorm coming, I know make it available on this site!!!