Hey!
Writing a simple client/server in C and I'm currently stuck with getting the results after calling system("ls") so I can send it from server to client.
Since system() returns an int I tried popen() -->
char buffer[1000];
FILE* myPipe = popen(buf, "r");
if(myPipe==NULL){
//errorstuff
}
while(fgets(buffer, 1000, myPipe)!=NULL){
(void) printf("%s \n", buffer);
}
pclose(myPipe);
But buffer only contains the last filename listed, not the rest of them. How do I get fgets to copy everything into the buffer?
As always; all help is appreciated! :o)