Thread: system command return values?

  1. #1
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905

    system command return values?

    does the system command return the value that was returned by the main() function in the called program?

    say i did this:

    Code:
    //PROGRAM NAME:  test.exe
    
    #include <iostream.h>
    
    int main()
    {
         cout << "Enter a number: ";
         int number;
         cin >> number;
         return number;
    }
    
    
    //PROGRAM NAME: main.exe
    
    #include <iostream.h>
    
    int main()
    {
         cout << system("test.exe") << endl;
         return 0;
    }
    now, theoretically, when you run main.exe, it should ask you for your number, then output it again directly below........but does the system command return anything? and also, is it os-dependant? because i noticed on XP it would return a 1 where in 98 it would return a 0......

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    I seem to remember that "test" is a valid command in Win98 (could be wrong though). Maybe Win98 gets confused with the conficting names.

    >>when you run main.exe, it should ask you for your number, then output it again directly below<<
    That's what happened when I ran your code on my WinXP.
    Code:
    Enter a number: 11
    11
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    yah, i know it works on XP, but i was wondering why it didn't work in 98......and i just used test.exe as an example

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>but i was wondering why it didn't work in 98
    Maybe because of the first thing I said. Try changing the name from test.exe to something else.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  5. #5
    Software Developer jverkoey's Avatar
    Join Date
    Feb 2003
    Location
    New York
    Posts
    1,905
    ARG, i just said above that i just used test.exe as an example!!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 1
    Last Post: 12-30-2007, 10:08 AM
  2. Need help with project
    By chrisa777 in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2006, 05:01 PM
  3. Sending values to a control
    By Zyk0tiK in forum C Programming
    Replies: 6
    Last Post: 12-02-2005, 06:29 PM
  4. New system build wont boot
    By lightatdawn in forum Tech Board
    Replies: 7
    Last Post: 12-02-2005, 06:58 AM
  5. Struct Values
    By Muphin in forum C++ Programming
    Replies: 5
    Last Post: 08-13-2005, 09:24 PM