How do I do this in c++?
It's driving me crazy.
thanks
How do I do this in c++?
It's driving me crazy.
thanks
Can you give more information on exactly what you're trying to do? Maybe an example?
At first glance I'd say you'd use a stringstream (or boost's lexical_cast if you have boost).
How do you use a stringstream?
I using some opencv function which takes a const char*, and I need to make the const char*'s I give it dynamic, hence I'm incrementing an int and converting to a const char*.
You can search for more examples and instructions:The str() returns a C++ string, and then c_str() is called on that string to return a const char*.Code:#include <sstream> // ... void func(const char*); // ... int your_int = 33; std::ostringstream ostr; ostr << your_int; func(ostr.str().c_str());
thanks, will try that in a sec
How can I do the following?
ostr << "a" + i + ".jpg" ;
where i is an int
error C2110: '+' : cannot add two pointers
Last edited by Wiretron; 11-12-2007 at 02:25 PM.
Use << instead of +.
It works like you were outputting those things to cout. You would use << there as well.