I have program in C where I compute something and result of that (integer) I need to return back to parent process, but it returns wrong values.
For example app.cpp
:
#include <stdio>
int main()
{
int i = 53400;
return i;
}
Parent process (in Perl language):
#!/usr/bin/perl
use strict;
use warnings;
my $res = system("./app");
print $res."\n";
If I return 0
in C, I get in parent process value of 0
.
If I return 1
in C, I get in parent process value of 256
.
If I return 2
in C, I get in parent process value of 512
.
So I thought that it is just multiples by 256, but I was wrong because if I return 53400
in C, I get in parent process value of 38912
which is not multiple of 256.
So how can I get correct value from child process in parent?