using pipe

Please, help me to understand how to use pipe!! I write the console application under Unix.
Here is the text:
char buff[1024];
FILE *stream;
stream=popen(stroka.c_str(),"r");
if(!stream){
std::cout<<"Error"<<'\n';
}
while(!feof(stream)){
while(fgets(buff,sizeof(buff),stream)!=NULL){
printf(buff);
}
};

pclose(stream);

There's string stroka(for example: "ls /tmp"), popen executes the command and outputs the results to the user. But popen it's C. How to use pipe?
Topic archived. No new replies allowed.