For example, Program a.out:
int main()
{
return 0x10;
}
Program b.out:
int main()
{
if(system("./a.out") == 0x10)
return 0;
else
return -1;
}
According to cppreference, the return value of system()
is implementation-dependent. Thus, the attempt of program b.out is obvious erroneous.
In the case above, how can I get 0x10
instead of an undetermined value?
If system call is not the right tool, what's the proper way to do this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…