Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mechanism for returning a string from C main() program

Tags:

c

I know that C program generally ends with return, where we return the status of the program. However, I want to return a string. The reason is that, I will be calling the C-executable from a shell script and printing the returned string. Is there any mechanism for the same ?

like image 568
Roopesh Majeti Avatar asked Nov 27 '22 18:11

Roopesh Majeti


1 Answers

There is no such mechanism; the return code is expected to be a byte. If you want to output a string from your program then use something like printf() and command substitution in the shell script to capture it.

like image 87
Ignacio Vazquez-Abrams Avatar answered Dec 19 '22 07:12

Ignacio Vazquez-Abrams