Okay I'm just learning so bear with me.
Suppose i have some code like this:
[code]
.
.
char name[4];
printf("Please enter your name:");
scanf("%s",&name);
printf("Your name is %s",name);
.
.
[\code]
Now I've set aside 4 characters for the name variable. However when I type in a name like Christopher I get the full name back.
Well haven't I specifically set the size for 4 characters? So why do I get 11 characters back in the output? Shouldn't my name be truncated after the 4th character?



LinkBack URL
About LinkBacks



