GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 23-Feb-2005, 04:10
shvalb
 
Posts: n/a
Question

Question about sprintf()


Hi.

I have a little question, I use the sprintf() like this:
CPP / C++ / C Code:
::sprintf(temp, "0%x%x", pUni->charValAndLang[k+1], pUni->charValAndLang[k]);

so the 'temp' (for instance) is 05d0, my question is, supposed I would like it to be %05%d0, how to I set the % char in the sprintf() ??

it supposed to be something like:
CPP / C++ / C Code:
::sprintf(temp, "%0%x%%x", pUni->charValAndLang[k+1], pUni->charValAndLang[k]);

no ?

Thanks.
Last edited by LuciWiz : 23-Feb-2005 at 06:20. Reason: Please insert your C code between [c] & [/c] tags
  #2  
Old 23-Feb-2005, 04:28
Dr. Evil Dr. Evil is offline
Member
 
Join Date: Oct 2004
Location: Netherlands
Posts: 120
Dr. Evil will become famous soon enough
To print the '%' character in any of the printf() functions you can use the '%%' format specifier to tell it to just print a percentage sign, so your code would probably look something like this:

CPP / C++ / C Code:
sprintf(temp, "%%0%x%%%x", pUni->charValAndLang[k+1], pUni->charValAndLang[k]);
 
 

Recent GIDBlogInstall Adobe Flash - Without Administrator Rights by LocalTech

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
non-member function question crq C++ Forum 1 03-Feb-2005 21:59
Simple question on arrays--please help! brookeville C++ Forum 16 17-Nov-2004 23:23
Repetition structure problem and question brookeville C++ Forum 17 29-Oct-2004 17:48
sprintf and snprintf question in C rn2388 C Programming Language 1 16-Jun-2004 15:11
question of practice magiccreative C++ Forum 1 06-Feb-2004 07:17

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 23:31.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.