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 |
an upper layer message is split into 10 frames each of which has an 80 percent chance of arriving undamaged.if no error control is done by the data link protocol,how many times must the message be sent on the average to get the entire thing through?
What are the differences between 1 dimensional RAM and 2 dimensional RAM?
what is difference between class and object in c++
synchronous and asynchronous transmission
Write a program in ‘C’ language that will perform the following operation on static stack. 1. push 2. pop 3. Display 4. Exit Create separate functions for each operation. The push() should accept one argument of structure type and will not return any thing. The pop() function will not receive any argument & return structure type value. The stack & top must be declare as external variable. Each element of stack 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
main() { int arr[]={12,14,16,18,20} printf("%u%u";arr+1,&arr+1); } //tell me the answer of this question with proper reason..:)//
What is meant by STL?
If Neena says "Anita's father Raman is the only son of my father-in-law Mahipal",then how is bindu ,who is the sister of Anita,related to Mahipal
I am going to HAL Online test for Computer Science. Can you please mail me the model question papers ?
What are the features of tata nano , technical specification of tata nano, overview of tata nano, varients of tata nano, price of tata nano, dealers of tata nano, expectation from tata nano, criticism of tata nano, tata nano hybrid ?
how 2 write a program of this pattern usin for loop?? 1 2 3 4 5 6 7 8 9 10
What is the weight of a foot square block of bronze.