Skip to main content

Thread: C++ - Strings and system()


playing around ubuntu 11.04, kernel 2.6.38-9-generic-pae , gcc 4.5.2, tinkering c++ in general. anyways trying open webpage in firefox, add int value end of string contains address , open new tab new link in well.

code:
 #include <iostream> #include <cstdlib> #include <string> #include <stringstream>  int main() { string website = "firefox www.google.com/"; stringstream test; int var = 3; test.str(website); test << var; system(test); }
the places goole brought talked using stringsteam job, compiler doesn't have been trying.
read bit stringstream @ http://www.cplusplus.com/reference/i.../stringstream/ not sure how implement it.

recap:

problem 1:
adding int var end of string.

problem 2:
sending appended string through system() command.

insight or info lead me understanding little better appreciated, thanks.

this should work, whatever attempting accomplish:
code:
#include <string> #include <sstream> #include <iostream> #include <cstdlib>  int main() {    std::string       website = "firefox www.google.com/";    int               var = 3;    std::stringstream test;     test << website << var;     system(test.str().c_str()); }


Forum The Ubuntu Forum Community Ubuntu Specialised Support Development & Programming Programming Talk [SOLVED] C++ - Strings and system()


Ubuntu

Comments