philpot345
June 7th, 2011, 06:22 PM
Playing around with ubuntu 11.04, kernel 2.6.38-9-generic-pae and gcc 4.5.2, tinkering with c++ in general. Anyways trying to open a webpage in firefox, then add an int value to the end of the string that contains the address and open a new tab with the new link in it as well.
#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 that goole brought up all talked about using stringsteam to do the job, but the compiler doesn't like anything I have been trying.
Read up a bit about stringstream at http://www.cplusplus.com/reference/iostream/stringstream/stringstream/ but just not sure how to implement it.
To recap:
Problem 1:
Adding an int var to the end of a string.
Problem 2:
Sending the appended string through the system() command.
Any insight or info that could lead me to understanding this a little better would be very much appreciated, thanks.
#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 that goole brought up all talked about using stringsteam to do the job, but the compiler doesn't like anything I have been trying.
Read up a bit about stringstream at http://www.cplusplus.com/reference/iostream/stringstream/stringstream/ but just not sure how to implement it.
To recap:
Problem 1:
Adding an int var to the end of a string.
Problem 2:
Sending the appended string through the system() command.
Any insight or info that could lead me to understanding this a little better would be very much appreciated, thanks.