in my c program i want to make a call to ls,but to store its output as a string without displaying it as stdin..ne suggetions?
in my c program i want to make a call to ls,but to store its output as a string without displaying it as stdin..ne suggetions?
Use a pipe:
Code:/* Potential example */ FILE *pin = popen("ls", "r"); char buffer[BIG_ENOUGH]; int i, c; while ((c = fgetc(pin)) != EOF) buffer[i++] = (char)c; pclose(pin);
Last edited by Prelude; 06-06-2005 at 09:42 AM.
My best code is written with the delete key.
popen() instead of fopen() maybe?
thanx..that helped..Originally Posted by ^xor
>popen() instead of fopen() maybe?
Force of habit, thanks for the heads up.
My best code is written with the delete key.