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 |
I need vlsi interview question papers
1 Answers HCL, Intel, Suzlon, TCS, UGC NET,
Please explain why you are suitable for the position that you have applied for?
i made lan connections ,then how can i establish the network....with that connections only is the network is established ...tell me the procedure for giving the lan connection for some(10) pc's?
what is the difference between oracle 8i and 9i. if someone could help me out.
What are the major network infrastructures for installing Exchange 2003?
is there any better model than jcb 3dx
how are engineers exploited in these days? why do they have to do mba in todays world?
how will u send the idoc
hey,frnds.....i want to do a telecom course, plz tell course and levels of that job.iam B.E (ECE) fresher.and also tell best institutes in hydrabad or banglore plz.
Is printf(?%d?,p); valid?
which one is best sorting technique and why?
WHAT IS THE DUMP ERROR?
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)