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 |
how to create user name stape by stape in cisco router {with command}
What is the basic difference between injection speed and injection pressure in an injection molding machine?
What is The Need of Template?
How we calculate the recovery of steam as per coal in a boiler if we know the calorific value of coal?
Explain Belady's Anomaly.
Create an midp application which examines that a phone number which has enters is in the given format * Area code should be one of the following:040,041,050,0400,044
PLZ SOMEONE TELL ME WHICH TYPE OF QUESTIONS IS ASKED IN HLL(Hindustan latex ltd.)mangmt trainee entrance exam?
4) Write a program that takes a 5 digit number and calculates 2 power that number and prints it. I did the following program and is this correct
Design a counter for the following binary sequence: 0,4,5,3,1,6,2,7 and repeat. Use JK flip-flops.
3 Answers IIIT, Infotech, University, UNW,
HELLO EVERYONE ON YAHOO , I'M IN NIGERIA AND I Will LIKE TO MOVE AND WORK IN CANADA , ANY SKILLED WORK IS OK BY ME AND THE PERSON WILL PAY THE BILL FOR IT, I WILL SERVE THE PERSON FOR THE EXPENSES.......... LOVE TO READ FROM YOU SOONEST AS YOU WISH TO HELP ME OUT
Draw the diagram showing the function stack, illustrating the variables that were pushed on the stack at the point when function f2 has been introduced . type def struct { double x,double y} point; } main( int argc, char *arg[3]) { double a; int b,c; f1(a,b); } f1(double x, int y) {point p; stack int n; f2(p,x,y) } f2(point p, double angle) { int i,j,k,int max;
Bhanu spends 30% of his income on petrol on scooter. ? of the remaining on house rent and the balance on food. If he spends Rs.300 on petrol then what is the expenditure on house rent?