GeekInterview.com
Series: Subject: Topic:
Question: 170 of 828

Field Width Specification

What is Field Width Specification?
Asked by: sivarama vinaykumar | Member Since Jun-2008 | Asked on: Jul 25th, 2008

View all questions by sivarama vinaykumar   View all answers by sivarama vinaykumar

Showing Answers 1 - 3 of 3 Answers
picc_kumar

Answered On : Sep 6th, 2008

View all answers by picc_kumar

Field width specification means to allocate the a particular fixed  size of a varriable whether varriable is small in size or big.eg:if we allocate a field width of a varriable is 10 and the varriable is a[5] then it will just take a five block in to ten and another five block will be free.by:- kamal kumar

  
Login to rate this answer.
kbjarnason

Answered On : Jul 1st, 2010

View all answers by kbjarnason

Presumably the question is about the width specifier on bit-fields:int x : 7;In this case, the width specifier (7 in our example) tells the compiler that the bit-field (x) will use 7 bits, rather than the default number for the type.The effect is to limit the range of allowable values to (in our example) the equivalent of what would be provided if the implementation used a 7-bit int type for x.Note that other than limiting the range, the semantics of the base type remain in effect.

  
Login to rate this answer.
jbode

Answered On : Jul 6th, 2010

View all answers by jbode

I'm assuming this is the minimum field width in a conversion specification for printf(), which specifies the minimum number of characters written to the output stream for that conversion.  For example, given the statementprintf("%10sn", "Hello");the 10 in "%10s" is the minimum field width; this means the value will be formatted so that at least 10 characters are written to stdout: "     Hello".  Note that this is a minimum width; if the value being written takes more than 10 characters to represent, then all the characters will be written, so the statementprintf("%10sn", "Supercalifragilisticexpealidocious");results in the output "Supercalifragilisticexpealidocious".  You can specify the field width at runtime by replacing the number with an asterisk and passing the value as an argument (int type):int width=10;printf("%*sn", width, "Hello");

  
Login to rate this answer.

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

Related Open Questions

Ads

Connect

twitter fb Linkedin GPlus RSS

Ads

Interview Question

 Ask Interview Question?

 

Latest Questions

Interview & Career Tips

Get invaluable Interview and Career Tips delivered directly to your inbox. Get your news alert set up today, Once you confirm your Email subscription, you will be able to download Job Inteview Questions Ebook . Please contact me if you there is any issue with the download.