Is there in C++ , a function like this ?

http://wiki.sa-mp.com/wiki/Format

there's a difference ... i don't want to see a formated string ... i want to create one , for example:

char s[128];
gets(s);
int d = 43;
char c = 'D';
format(s,sizeof(s),"String is: %s | Integer is: %d | Caracter is: %c",s,d,c);
and all this will be putted in s and if i want to see the vals , i do:
cout << s;
or
printf("%s",s);

Or something else and will print:

String is: (what i typed) | Integer is: 43 | Caracter is: D

>there's a difference ...
Only in your mind. What you described is exactly what sprintf will do for you.

First off, anyone using gets(s); needs their head examining.

> format(s,sizeof(s),"String is: %s | Integer is: %d | Caracter is: %c",s,d,c); And this differs from the following in what way? snprintf(s,sizeof(s),"String is: %s | Integer is: %d | Caracter is: %c",s,d,c); Further (what, you mean there's more?) format(s,sizeof(s),"String is: %s | Integer is: %d | Caracter is: %c",s,d,c); Using the same buffer for input AND output is real bad mojo (if you want to be technical, it's undefined behaviour).

All you're likely to end up with is a string full of
String is: String is: String is: String is: String is: String is:
or something worse, like wondering where your OS reinstall disks are.

commented: Nice. +1
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.