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
#include
difference between tcp ip and open system interconnection
WRITE A C PROGRAM TO REVERSE THE LINK LIST WITHOUT CREATING NEW LIST?
iam from engineering information technology ... can i write group 1 exams??
how to increase the water ring vacuum pump efficiency?
what is a query for divide a table into two subtable?
what things abutsbi
plz tell me which books r important for gate exam (CSE)
Is Diesel staorage tank ( 800 litres) cleaning procedure is available with any body
is built-in data-type are abstract data-types in java
List three things you can do with the files you create by recording your voice on your computer
WHY WE SELECT U AS A PERTOLEUM ENGINEER THOUGH UR MARKS ARE LESS THEN OTHER APPLICANTS
what is the quantity of cement and sand in 1 sq.m (mortar ratio ) a, 1:4 b, 1:3 c, 1:6
how can one get scholership based on gre score ang how much scholarship one can get, plz suggest the way one can apply and get scholarship
i cannot go to my computer to set up why?