Can any one tell me how to return the output of a program in a variable from command line?
var = ./a.out params
I am trying to get the outp
You can pass value from your program to shell via stdout (as was already said) or using return statement in your main() function from your C program. One-liner below illustrates both approaches:
echo -e '#include
Output:
22
11
Variable a is printed to stdout and variable b is returned in main(). Use $? in bash to get return value of most recent invoked command (in this case ./a.out).