0
When I run the following code it stores the output status of the command wc -l
which has value 0 as it has been successfully executed.
#include <stdio.h>
#include <stdlib.h>
int main() {
int status = system("echo 'hello world' | wc -l");
printf("%d", status);
return 0;
}
But what I need is the result value of this command, which in this case became 1. How do I store this result in a variable in C??
That helps me a lot! But I still have a question... how do I isolate this code in a function that receives a string from a command and returns a result?
– Gabriel Hardoim