-
Is this normal?
I was just experimenting with idea's and i wrote a program
to check what another program returns.
such as if it ran successful my program would display a 0,
because that what the program main() would return.
anyways this is the code :
Code:
#include <iostream>
#include <process.h>
using namespace std;
int main()
{
int check;
check = system("\"D:\\Documents\\Visual C++ Projects\\variablework\\Debug\\variablework.exe\"");
cout << check << endl;
cin.get();
return 0;
}
and this is the code of the program i checked
Code:
#include <iostream>
using namespace std;
int main()
{
cout << "poop" << endl;
return 156;
}
Now my question is, when i run the first program and it runs the
2nd program it displays the return amount in my program like it
should, but it also displays the word i set in the cout statment of
the 2nd program. This doesnt seem normal to me. Any insight is
appreciated.
-
In order to get to "return 156", cout must be called. It's program execution, man. Your first program is calling the second program and using its return value.
-
Yes i know this but, what im saying is i did not realize because it
doesnt seem right that the content of program one would be
displayed in program 2.
to clear that statment up even more, why does the cout statment
of program 1, show up in program 2, when all program 2 is doing,
or should be doing is recieving the return amount and displaying
it. WHy does it display the cout of program 1 in program 2.
-
OK nevermind i see why its doing that during this particular instance.