KF> While I'm here though, could you please tell me why this doesn't work
KF> porperly:
KF> char name[30];
KF> printf("Please Enter Name: ");
KF> scanf("%s",name);
KF> when this inputs the string, if I have a space in bewteen something
KF> (for example "Keith Fowler") it only puts
"Keith" in the name[30], then if
That's what scanf does - stop at the first space.
KF> I do another scanf it then puts "Fowler" starigh into that
string....
KF> Am I using a wrong command??, or am I using this one wrong?, if ya
KF> could help me out it would be great!.. Thanks..bye
If you want to read in a whole line, I suggest:
fgets(name, sizeof name, stdin);
You will then need to strip the '\n'.
You could use:
gets(name);
which strips the '\n' for you, but that has no max-length protection. BFN. Paul.
@EOT:
---
* Origin: X (3:711/934.9)
|