can we specify variable field width in a scanf() format
string? if possible how in c language?
Answer Posted / 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 |
Post New Answer View All Answers
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.
what do you expect from this company?
what is the difference b/w "print" and "sprint" in sql?
My gre score is 283 and ielts is 5.5, will i get i20 for this score
how strcpy usingrecursive function
What are the inspection and test plan for lift materials?
what is a query for divide a table into two subtable?
What are annotations? What are assertions? why they are used why not if-else?? what is normalization? what is QuickSort? what are Avl trees?
What kind of question can be asked at the time of Interview for State Bank Of India Clerical Interview
what are the various height of GSM mount and its base width ashim.port@gmail.com
what are the artifacts in coding phase in SDLC????
What are the main assumptions that we make when we model potential flow?
WHAT IS THE NAMESPACE FOR CUSTOMCONTROL AND USER CONTROL IN ASP.NET?
I am selected interview for computer sc.please give me some information how many types question asked in interview.my id is sumanadas10@gmail.com
WHY IBM MAINFRAME TECHNOLOY IS USED.THOUGH, SINCE ITS INTRODUCTION IT HAS NO MAJOR UPDATATION OR MODIFICATION;BUT STILL IT IS IN DEMAND........WWWWWWWWWWWWWWHHHHHYYYYYYYY????????????