What should I do to get all the return value of a c-program from the command line?
I have a simple C-program "./my_program"
#include <stdio.h> int main (int argc , char **argv) { unsigned int return_result = 0x474; printf("return_result = %d = 0x%x \n",return_result,return_result); return return_result; }
As a result, this program prints:
return_result = 1140 = 0x474
I want to get the return value of a c program in a bash script. According to this link Anyway, to get the return value of a c-program from the command line? Should I get this variable from $?
But when I run such commands, the result is:
./my_program echo $?
I get
116
Obviously, 116 = 0x74 (low byte). But I would like to get all the value of unsigned int. What's wrong? What should I do to get all the return value of a c-program from the command line? This is not just about the type "unsigned int". What if I created a complex type, for example, a structure.
I tried this:
return ((unsigned int) return_result_section_size);
This does not work.
Unix exit codes are limited to one byte . If you want to output more, you can write it to stdout or to a file.
Then why is the standard C statement that main
returns int
, not char
? I have no idea...