I give you a simplified example to explain what I would like to do.
I have the following code, which I cannot modify (hello.cpp):
|#include <iostream>
#include <fstream>
using namespace std;
int main( int argc, char *argv[] )
{
string line;
ifstream f( argv[1] );
while(!f.eof())
{
getline(f, line);
cout << line << endl;
}
return 0;
}
Launch example:
||caneta@host ~ $ ./hello myfile.txt
1 - This is
2 - a test
3 - file.
I have a wrapper program which I need to modify:
||#include
#include
#include
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
int main ()
{
int ret;
ret = execl ("./hello", "./hello", "myfile.txt", (char *)0);
return 0;
}|
In this way it works perfectly...but how can I modify it in order to use
a stream or a string inside the wrapper program, instead of using a file
name?
I would like to have something like:
|#include
#include
#include
#include <iostream>
#include <fstream>
#include <sstream>
using namespace std;
int main ()
{
int ret;
ifstream inputFile;
inputFile << "1 - This is" << endl;
inputFile << "2 - a test" << endl;
inputFile << "3 - file." << endl;
ret = execl ("./hello", "./hello", inputFile, (char *)0);
return 0;
}|
This last example, of course, doesn't work...how can I modify it in
order to make it work?
Remember that I cannot modify hello.cpp...
Can the Boost.iostreams help me?
Thanks in advance.
--
Alessandro Candini
MEEO S.r.l.
Via Saragat 9
I-44122 Ferrara, Italy
Tel: +39 0532 1861501
Fax: +39 0532 1861637
http://www.meeo.it
========================================
"ATTENZIONE:le informazioni contenute in questo messaggio sono
da considerarsi confidenziali ed il loro utilizzo è riservato unicamente
al destinatario sopra indicato. Chi dovesse ricevere questo messaggio
per errore è tenuto ad informare il mittente ed a rimuoverlo
definitivamente da ogni supporto elettronico o cartaceo."
"WARNING:This message contains confidential and/or proprietary
information which may be subject to privilege or immunity and which
is intended for use of its addressee only. Should you receive this
message in error, you are kindly requested to inform the sender and
to definitively remove it from any paper or electronic format."