Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sprintf(const char* format, ...)?

Status
Not open for further replies.

inetd

Technical User
Jan 23, 2002
115
HK
How can I write a function like this:

AnsiString::sprintf(const char* format, ...)?

Thanks.
 
There are several ways depending upon what effect You want.
If it's because You want to have adjustable alignment of digits use the sprintf(Buffer,"%*u",Number_Of_Digits,Variable_To_Show).
If You want to make special tricks fill an array of strings with the descriptors and select the appropriate of them:
char * Descriptor[] = {"%3u","%03u","%-3u","%-03u"};
sprintf(Buffer,Descriptor[Index],Value_To_Show);
Be more specific if this does not cover it.

Totte
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top