Thanks for this Post it helped me a bit
returning value from called function in shell script
I have written a code like below :
File.c
i = system("/home/ubuntu/Documents/Flash_Desk_App/Project/test.sh -c");
printf("SH = %x",i);
test.sh
ONE=1
echo " Hello world "
clean()
{
CLEAN_FLAG=1
echo $ONE
return "$ONE"
}
option="${1}"
case ${option} in
-c)
echo "Cleaning"
clean
;;
*) echo "Usage"
usage
;;
esac
but when i execute my ./a.out this is the output
Hello world
Cleaning
1
SH = 0
IT ALWAYS PRINTS 0. CAN SOME ONE GUIDE ME IN SOLVING THIS. i WANT TO COLLECT THE VARIABLE VALUE RETURN BY SHELL IN MY C CODE.