I am running a system call within my main function and I wanted to know if I could read the command line output from the system call line by line within the main function.
I have been looking online for any tips or ideas on how to do this, but I cannot find any. One thing to note is that I do not want the output to be written into a file and then read from that file, but rather read the command line output line by line.
int main(int argc, char const *argv[]) {
system("ls -al");
return 0;
}
For example, in the above code, I want to print all the files in the current directory through this C function. With that information, I only want to print the ones that have been updated in April (distinguished with an "Apr" in the 6th column). Is it possible for me to read the output line by line, split the line into an array and check to see if the specified column is "Apr", and if so how? Any and all help/advice would be highly appreciated.