IT Community - Software Programming, Web Development and Technical Support

% in C ?

This is a discussion on % in C ? within the C and C++ Programming forums, part of the Software Development category; In c we put % before 'd' or '%S' Wt mean by '%'. EXample Printf("%d %s",id,name);...


Go Back   IT Community - Software Programming, Web Development and Technical Support > Software Development > C and C++ Programming

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-16-2007, 05:47 AM
prasath prasath is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Location: Chennai
Posts: 173
prasath is on a distinguished road
Question % in C ?

In c we put % before 'd' or '%S'

Wt mean by '%'.


EXample

Printf("%d %s",id,name);
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 07-16-2007, 06:54 AM
Sabari Sabari is offline
D-Web Genius
 
Join Date: Jul 2007
Posts: 1,008
Sabari is on a distinguished road
Default Re: % in C ?

hi prasath,

% means - print formatting is controlled by 'format identifiers'

Example:
--------
char name[20] = "Buddies";
int age = 5;
printf( "Hello %s, you are %d years old\n", name, age );

displays the following output:

Hello Buddies, you are 5 years old

1. The %s means, "insert the first argument, a string, right here."
2. The %d indicates that the second argument (an integer) should be placed there. like that there are different %-codes for different variable types.
__________________
Thanks & Regards
Sabari...

Last edited by Sabari : 07-16-2007 at 07:30 AM.
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-16-2007, 11:34 PM
prasath prasath is offline
D-Web Sr.Programmer
 
Join Date: Jul 2007
Location: Chennai
Posts: 173
prasath is on a distinguished road
Exclamation Re: % in C ?

Hi sabari,
is it possible when u use string insted of format identifier

For example:

printf( "Hello %s, you are %d years old\n", name, age );
C compilier can accept the above code?


Thanks,
Prasath.K
Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -7. The time now is 07:12 PM.


Copyright ©2004 - 2007, DiscussWeb. All Rights Reserved.

SEO by vBSEO 3.0.0