This is a very simple question, and I feel stupid asking about it, but I click on the time and I need to find out :)
I just need to know how to create a string containing text and other variables. For example, in Java, I can just do this:
String someString; for(int i = 0; i>10; i++){ someString = ("this text has printed " + i + " times"); //how do I create this line in C++? System.out.println(someString); i++; }
EDIT 4:
Ok, the Rahul G answer below works very well, and the program compiles and works fine, but when I run it instead of getting the line I want for the file name, I get a bunch of numbers. For example: << "frame " << i << " .jpg" creates: "013679000.jpg" instead of "frame 0.jpg" as I want. Any thoughts?
for(int i = 0; frames; i++) { frame = cvQueryFrame(capture); std::string s = static_cast<std::ostringstream &>(std::ostringstream() << argv[1] << i << " .jpg").str(); cvSaveImage(s.c_str(), frame); }
c ++ string
ubiquibacon
source share