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
How I can write a java program output the following 1+2+4+7+......N
how the parting surface is selected in injection mould
Why is using C language
what is need of interface. what is the diff b/w interface and abstract class
what are the reseach done by itc brfore launching e-copal
i am going to give interview for the post of ibps po..so there is a question in my mind which is "Being an electonics and communication engineer how can you help in banks, I mean whats the application of your education in banking."
c# code, vb.net code language parity refers to what?
is it possible to get u.s visa with 55% in b-tech and 15 backlogs
What is Mointer in Operating System?
what are the various login options used in loadrunner tool to make a application performance testing
Which is better field cad/cam in mechanical or film editing/animation is better salary wise?
How we calculate steam turbine governor linkage assembly?
CSS corp interview process and placement papers
is the used fire extinguisher fall under Hazardous waste material?
can you provide me uniken pvt ltd. technical interview question and answer?