What should I do to get the whole return value of c-program from command line?

后端 未结 2 1781
再見小時候
再見小時候 2021-01-18 14:35

I have a simple C-program \"./my_program\"

#include 

int main (int argc , char **argv) {


   unsigned int return_result = 0x474         


        
相关标签:
2条回答
  • 2021-01-18 14:59

    Exit codes on Unix are restricted to a single byte. If you want to output more, you could write it to stdout or to a file instead.

    Then why does the C standard decree that main returns int and not char? I have no idea...

    0 讨论(0)
  • 2021-01-18 15:00

    The value returned from main can be printed using echo $? after you are done with the execution. The return value from main is generally used to indicate the execution status. The max value is limited to 512. If you try to return a greater value than 512, 512%val would be set in $?.

    0 讨论(0)
提交回复
热议问题