Exforsys
+ Reply to Thread
Results 1 to 2 of 2

Confused on Return Status

This is a discussion on Confused on Return Status within the C and C++ forums, part of the Programming Talk category; I am using UNIX operating system and now I am trying out quite a number of programs in C programming ...

  1. #1
    Adrian is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    124

    Thumbs up Confused on Return Status

    I am using UNIX operating system and now I am trying out quite a number of programs in C programming language in my UNIX environment. I recently came across a function named as system() and thought of trying out this by a sample program to get idea about this function. I wrote the below C code for that

    main()
    {
    int a = system("excel.exe");

    }

    I know that the above would open excel and exist from this only when the users exit from this. But the point I am confused is what is the return status from this system() function. Will it be the exit code of the excel process? Kindly clarify me on this.


  2. #2
    Ralph is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    114
    Many might think that the function system() would return the exit code of the process initiated namely excel.exe. But it is wrong. The system() function instead returns the exit code of the shell that initiates the process. In your example the system() function would return the exit code of the shell that initiated excel and would not return Excel’s exit status.


Latest Article

Network Security Risk Assessment and Measurement

Read More...