can we specify variable field width in a scanf() format
string? if possible how in c language?
Answer / deepedra kushwaha
You can't specify a variable field with a fixed format
string, but you can get around this by making the format
string variable:
int width;
char format[20]; /* or whatever size is appropriate */
int value;
...
sprintf(format, "%%%dd", width); /* generates a string like
"%5d" */
scanf(format, &value);
The only drawback to this method, other than requiring two
statements, is that the compiler can't do a sanity check on
the arguments to scanf like it can when the format is a
string constant.
Read more:
http://wiki.answers.com/Q/Can_you_specify_variable_field_width_in_a_scanf_format_string_If_possible_how#ixzz1bSMgbeUL
| Is This Answer Correct ? | 1 Yes | 0 No |
what is the main fuction of OSPF in a internetwork? how does work of same network?
Why viruses wont affect Linux systems?
successful command to make linux system as router in redhat-+
different types of protocols.......?
why there is a collision in switch
What is the aim of Value Engineering?
0 Answers BPCL Bharat Petroleum,
Please send the details and fee for Intools training course..I would like to do the course in second week of jUNE 2010.
what is difference between Fault tolerance Vs fault avoidance
Active Directory interviews questions
why bin folder is not be created in windows os?
hi friends i am first time using this site.i came to by some tcs personals that certifications r important for placements.i am financially average i am learning java from books.please tell is it enough if not which certification should i go for
can i knw what are we supposed to read for the coming oces/dgfs 2009 exam?what kind of book are we supposed to study?
Civil Engineering (5086)
Mechanical Engineering (4456)
Electrical Engineering (16639)
Electronics Communications (3918)
Chemical Engineering (1095)
Aeronautical Engineering (239)
Bio Engineering (96)
Metallurgy (361)
Industrial Engineering (259)
Instrumentation (3014)
Automobile Engineering (332)
Mechatronics Engineering (97)
Marine Engineering (124)
Power Plant Engineering (172)
Textile Engineering (575)
Production Engineering (25)
Satellite Systems Engineering (106)
Engineering AllOther (1379)