E EngenZerO Diamond Member Dec 24, 2001 5,099 2 0 Feb 22, 2004 #1 Hey I have a quick question.. how can one take a specific integer and add it to a set of characters. This needs to be an specific item. I just cant use sprintf/printf. ex. taking 1 and xx to produce -> 1xx.
Hey I have a quick question.. how can one take a specific integer and add it to a set of characters. This needs to be an specific item. I just cant use sprintf/printf. ex. taking 1 and xx to produce -> 1xx.
BFG10K Lifer Aug 14, 2000 22,709 3,003 126 Feb 22, 2004 #2 Do you need to store it or just print it? If you need to store it you could use an output string stream.
Do you need to store it or just print it? If you need to store it you could use an output string stream.
E EngenZerO Diamond Member Dec 24, 2001 5,099 2 0 Feb 22, 2004 #3 store it as a variable so that another program can read it..... we are learning about shared memory. right now I am attempted to mess with this iota command.
store it as a variable so that another program can read it..... we are learning about shared memory. right now I am attempted to mess with this iota command.
S singh Golden Member Jul 5, 2001 1,449 0 0 Feb 22, 2004 #4 Here's one way: #include <sstream> using namespace std; .... Assume integer has the number. The string 'combined' will have the result .... ostringstream oss; oss << integer; string combined = oss.str() + "xxx";
Here's one way: #include <sstream> using namespace std; .... Assume integer has the number. The string 'combined' will have the result .... ostringstream oss; oss << integer; string combined = oss.str() + "xxx";
T TerryMathews Lifer Oct 9, 1999 11,464 2 0 Feb 22, 2004 #5 It's been awhile, but try something like this. int num = 1; string word = "fineday"; string sentence = (string)num + word;
It's been awhile, but try something like this. int num = 1; string word = "fineday"; string sentence = (string)num + word;
EagleKeeper Discussion Club Moderator<br>Elite Member Staff member Oct 30, 2000 42,589 5 0 Feb 23, 2004 #6 Even though you stated your can not use sprintf, there must be another reason string_buffer; sprintf(string_buf,%d%s",int_var,string_var); or string string_buffer; string_buffer = itoa(int var) + string_var;
Even though you stated your can not use sprintf, there must be another reason string_buffer; sprintf(string_buf,%d%s",int_var,string_var); or string string_buffer; string_buffer = itoa(int var) + string_var;