|
From: Erik S. <esc...@gm...> - 2006-05-08 21:53:18
|
I was told to use fileno and an fstream constructor to convert a
FILE* to an fstream.
I'm trying to do this on a mac, here's the ode that failed:
#include <iostream>
#include <cstdio>
#include <string>
#include <fstream>
using namespace std;
int main(int argc,char *argv[]){
fstream pipe(fileno(popen("ls","r")));
string total;
char c;
cout<<"initialized"<<endl;
while((pipe.get(c))!=NULL){
total+=c;
}
cout<<total<<endl;
pipe.close();
return 0;
}
any ideas why this doesn't work
|