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
Explain i.d.e. for visual c++?
Modal vs Modaless in VB??
what do you expect from this company?
why view is created in database
Write a test case plan for a typical banking application which involves functionalities like Balance enquiry, deposit, fund transfer etc. Make your assumptions and mention the same in your answer sheet.
plz snd me sbi probationofficers papers to my id archpa@gmail.com
Write a C/C++ program that connects to a MySQL server and checks if the InnoDB plug-in is installed on it. If so, your program should print the total number of disk writes by MySQL.
hi i am avinash ,i am doing ma b-tech(cse) final year and i have been detained for 2years due to attendance and i will be finished ma b-tech in 6 years ,plz tell me weather i will be eligible for government jobs like bhel, drdo,or any other private companies
What is the dewpoint of atmoshperic Air?
10. Write a program in āCā language that will perform the following operation on double link list. Each node of this list contains the address of previous as well as next node. The previous pointer of first node & next pointer of last node should contain null. 1. Creation of list with as many records as user want 2. Search a node in the list 3. Deletion at last position 4. Display 5. Exit Create separate functions for each operation. The create () will be used to create the list. It should accept no argument & return the address of the starting node. Search() will search a node in the list. It receives rollno as argument & return that node if found otherwise return null. The delete () function will delete the last node. It does not receive any argument & return structure type value at last position. The starting node of the double list must be declared as external pointer variable. Each element of double link list will contain the following information Roll No, Std Name, Course. Use do-while loop & switch case for generating the above menu. The format of the output should is given below: S.No. Roll No. Student Name Course 1 cse01 Anil Singh B.Tech
when did actually oil exploration start
can i learn ad. java without learned core java? java is best or .net is best for summer training?
I want to join for load runner training..please suggest me which is the best institute for load runner training in bangalore?
What is candidate key ? What is Alter net key ? & What is foreign key ?
What is diff b/w TON and BTU for Air conditioner?