When the program starts I need to prompt for the Users name and store it in an array . I need to be able to frequently insert it in the printf("Ben (this was entered earlier) , please enter blah blah...") like so. Can someone please help me with this. I appreciate any help , or even a link where I can look it up as I was not able to find much on this . Thank you :)
Storing a name in array using C?
There are two ways, select which you feel suitable
first
char *name; // no matter if name istoo long
printf("Enter your name:");
scanf("%s",name); //or you can use
//gets(name);
//to print simply
printf("%s",name);
or by using arrays
char name[20]; //length limited upto 20 chars only
printf("Enter name:");
scanf("%s",name);
printf("%s",name);
Reply:http://www.scit.wlv.ac.uk/cbook/chap6.ar...
#
Reply:I don't get a full picture of what you want out of your question. I presume you are trying to deal with some kind of array of structured objects.
This site might guide you through..
http://vergil.chemistry.gatech.edu/resou...
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment