Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check the value which my program returns?

Tags:

c

linux

shell

i have created a program in C. I would like to know, how to check the value which my program returns ... I mean, at the end of the code my program return zero if no error occurred. If an error occurred my program should return 1. And that's the problem, i want to see if really 1 is returned if something went wrong. For memory leaks, etc I am using valgrind on Linux. Thank you for any help.

like image 888
user1852954 Avatar asked Dec 27 '22 14:12

user1852954


1 Answers

You can just print the special shell variable $?, e.g.:

$ ./my_program ; echo "status = $?"
like image 184
Paul R Avatar answered Jan 08 '23 06:01

Paul R