"%5.3d" in C program language

Discuss your favorite war-based hat simulator.

"%5.3d" in C program language

by ribben89 » Fri Nov 16, 2012 12:49 am

What's the meaning of "%5.3d" in C program language?Could someone help me?Thanks so much. :D :D :D
ribben89
 
Posts: 1
Joined: Fri Nov 16, 2012 12:46 am

Re: "%5.3d" in C program language

by LegendarySurgeon » Fri Nov 16, 2012 10:08 am

it's a print parameter, I'll break it down for you:

% is the special character letting the printf know, Hey! This is indicating some data you should display
5 indicates that it should display at least 5 characters and will pad with extra blank space on the left (but won't truncate).
.3 indicates that it should display at least 3 numbers and will pad with 0s on the left. If it were a float it would do something different but that's another story.
d indicates that it's printing a signed decimal integer, so

So for example if you tried to printf("%5.3d",5) you would get " 005"

Also, see here: http://www.cplusplus.com/reference/clib ... io/printf/
The mills of the gods grind slowly, but they grind exceedingly fine.

Image
User avatar
LegendarySurgeon
Donator
☺ Dabbling Conversationalist
 
Posts: 984
Joined: Sun Jan 02, 2011 7:49 am
Location: Seattle, WA, USA

Re: "%5.3d" in C program language

by Vivi Hill » Fri Nov 16, 2012 8:30 pm

I'm pretty sure this is a spambot. Usually they'll have random questions like this, post in the wrong subforum, and then have a single link to a website.
Image
"Just because nobody complains doesn't mean all parachutes are perfect." --Benny Hill
User avatar
Vivi Hill
Red Admin
Master of Ceremonies
 
Posts: 1498
Joined: Sat Oct 09, 2010 12:27 pm
Location: Troy, NY

Re: "%5.3d" in C program language

by LegendarySurgeon » Sat Nov 17, 2012 10:01 am

Benny Hill wrote:I'm pretty sure this is a spambot. Usually they'll have random questions like this, post in the wrong subforum, and then have a single link to a website.

Yeah, I figured as much. Though I do find it funny that you posted here just minutes after me but then deleted your post =P
The mills of the gods grind slowly, but they grind exceedingly fine.

Image
User avatar
LegendarySurgeon
Donator
☺ Dabbling Conversationalist
 
Posts: 984
Joined: Sun Jan 02, 2011 7:49 am
Location: Seattle, WA, USA


Return to Team Fortress 2



Who is online

Users browsing this forum: No registered users and 1 guest