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 m doing btech with computerscience branch.For every campus placement eligibilty criteriais is 60%.I have 65% in highschool and b.tech till now but secured 59.6% in intermediate. So would this percentage b considered as 60% or i wont b able to sit in exams?kindly post your views?
How to freely move a ball in graphics mode.
How many VLANs are supported on a single switch
what is polymorphism.
2 ships are wardroom light house one side at 30 degree and other ship other side at 45 degree. If light house has 100 m, find distance of boat from light house. and also find distance of each boat from light house
where is the first engeenering college of Asia
Write a program to maintain a singly linked list having the following functions: a) Creation of the list b) Displaying the list. c) Swap all nodes at consecutive even odd positions. E.g.: The nodes at position 1 should be swapped with node 2, node 3 with node 4 and so on.
which type of casting enforces type safety
what are the different types of database servers
What is the full forms SDDC,TOR,DLRO,PPP,USW,AWWA,CMOS,SVI,
I APPLIED SBIPO EXAM PLZ SEND ME THE INTERVIEW QUESTIONS AND GD TOPICS AND WRITTENEXAM QUESTIONS
Can have i call constructor in interface?