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?



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

Post New Answer

More Engineering AllOther Interview Questions

I need vlsi interview question papers

1 Answers   HCL, Intel, Suzlon, TCS, UGC NET,


Please explain why you are suitable for the position that you have applied for?

0 Answers  


i made lan connections ,then how can i establish the network....with that connections only is the network is established ...tell me the procedure for giving the lan connection for some(10) pc's?

0 Answers  


what is the difference between oracle 8i and 9i. if someone could help me out.

0 Answers  


What are the major network infrastructures for installing Exchange 2003?

0 Answers   Wipro,


is there any better model than jcb 3dx

0 Answers  


how are engineers exploited in these days? why do they have to do mba in todays world?

1 Answers  


how will u send the idoc

0 Answers   HCL,


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.

0 Answers  


Is printf(?%d?,p); valid?

0 Answers  


which one is best sorting technique and why?

1 Answers   TCS, Wipro,


WHAT IS THE DUMP ERROR?

1 Answers   CTPS,


Categories
  • Civil Engineering Interview Questions Civil Engineering (5086)
  • Mechanical Engineering Interview Questions Mechanical Engineering (4456)
  • Electrical Engineering Interview Questions Electrical Engineering (16639)
  • Electronics Communications Interview Questions Electronics Communications (3918)
  • Chemical Engineering Interview Questions Chemical Engineering (1095)
  • Aeronautical Engineering Interview Questions Aeronautical Engineering (239)
  • Bio Engineering Interview Questions Bio Engineering (96)
  • Metallurgy Interview Questions Metallurgy (361)
  • Industrial Engineering Interview Questions Industrial Engineering (259)
  • Instrumentation Interview Questions Instrumentation (3014)
  • Automobile Engineering Interview Questions Automobile Engineering (332)
  • Mechatronics Engineering Interview Questions Mechatronics Engineering (97)
  • Marine Engineering Interview Questions Marine Engineering (124)
  • Power Plant Engineering Interview Questions Power Plant Engineering (172)
  • Textile Engineering Interview Questions Textile Engineering (575)
  • Production Engineering Interview Questions Production Engineering (25)
  • Satellite Systems Engineering Interview Questions Satellite Systems Engineering (106)
  • Engineering AllOther Interview Questions Engineering AllOther (1379)