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 |
how the parting surface is selected in injection mould
what is static identifier in c language?
Why is not creat swap partition in my system.
write a c programme to count the characters words and lines in a text book
What is the relation between dB and change of signal?
what should be the finish work of a carpenter per day
Whay we use gigabite ethernt
What are the methods available in storing sequential files ?
What would be the difficulties with building a bridge that connects the UK and Canada?
Hi friends..cud any help to get QC 9.2 trial..i tried with HP site but did'nt got it..please help me out
What kind of question can be asked at the time of Interview for State Bank Of India Clerical Interview
I need a last 3 years question paper for RRB exam,post of section engineer(computer science)
Civil Engineering (5086)
Mechanical Engineering (4453)
Electrical Engineering (16638)
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)