Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

hey,frnds.....i want to do a telecom course, plz tell course and levels of that job.iam B.E (ECE) fresher.and also tell best institutes in hydrabad or banglore plz.

2048


what do you expect from this company?

2238


what is the difference b/w "print" and "sprint" in sql?

1886


My gre score is 283 and ielts is 5.5, will i get i20 for this score

1455


how strcpy usingrecursive function

2026


What are the inspection and test plan for lift materials?

2021


what is a query for divide a table into two subtable?

2040


What are annotations? What are assertions? why they are used why not if-else?? what is normalization? what is QuickSort? what are Avl trees?

2360


What kind of question can be asked at the time of Interview for State Bank Of India Clerical Interview

2100


what are the various height of GSM mount and its base width ashim.port@gmail.com

1842


what are the artifacts in coding phase in SDLC????

2191


What are the main assumptions that we make when we model potential flow?

1044


WHAT IS THE NAMESPACE FOR CUSTOMCONTROL AND USER CONTROL IN ASP.NET?

2095


I am selected interview for computer sc.please give me some information how many types question asked in interview.my id is sumanadas10@gmail.com

1812


WHY IBM MAINFRAME TECHNOLOY IS USED.THOUGH, SINCE ITS INTRODUCTION IT HAS NO MAJOR UPDATATION OR MODIFICATION;BUT STILL IT IS IN DEMAND........WWWWWWWWWWWWWWHHHHHYYYYYYYY????????????

1969