system spawns a new shell process that is not connected to the parent through a pipe or something else.
Instead, you need to use the popen library function. Then read the output and push each line into your array when you encounter newline characters.
FILE *fp = popen("grep -A1 \"<weakObject>\" file_name | grep \"name\" | grep -Po \"xoc.[^<]*\" | cut -d \".\" -f5 ", "r"); char buf[1024]; while (fgets(buf, 1024, fp)) { } fclose(fp);
Blagovest buyukliev
source share