Thread: return value from main()

  1. #16
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    The FAQ has a detailed description of spawn() and family, and it uses process.h. http://faq.cprogramming.com/cgi-bin/...&id=1043284392

    Try searching your header files, I'm sure that one of them has "spawn". I think that some systems use posix_spawn_something().

    The Wikipedia entry has lots of information about spawn(): http://en.wikipedia.org/wiki/Spawn_%28computer%29
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  2. #17
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129
    http://en.wikipedia.org/wiki/Process.h seems to suggest that process.h is a windows specific header.

  3. #18
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,057
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  4. #19
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    Quote Originally Posted by megastar View Post
    but i think the part where you try to do
    iRet=system(szProgram);
    the RETURN VALUE OF THE SYSTEM NEED NOT BE THE RETURN VALUE OF PROGRAM.
    Indeed, quite correct.

    Quote Originally Posted by megastar View Post
    This was according to the link given by zacs7.
    This was also given in my post in this topic:

    Quote Originally Posted by MacGyver View Post
    rv can indeed be the return value of the program. Whether it is or not depends upon other factors, such as whether or not the command you ran was actually able to be executed or not.
    This matches what you discovered:

    Quote Originally Posted by megastar View Post
    I also ran your 3rd program and i was getting the output 32512 on passing
    the name of any file.
    http://www.cplusplus.com/reference/c...ib/system.html
    I found this having to do with ruby, but I find the return value interesting. More googling indicates that the value 32512 is a value that can be obtained from system().

    Quote Originally Posted by megastar View Post
    Any suggestions?
    I did warn that the programs I provided are proof of concept, and while I would encourage people to experiment, to be prepared for this. They naturally worked for me, but I have little confidence in system()'s portability in this regard since it relies heavily on the behavior of O/S-specific shells, and I admit I know not much about the underlying mechanisms for most systems.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how to combine these working parts??
    By transgalactic2 in forum C Programming
    Replies: 0
    Last Post: 02-01-2009, 08:19 AM
  2. Another weird error
    By rwmarsh in forum Game Programming
    Replies: 4
    Last Post: 09-24-2006, 10:00 PM
  3. DirectInput help
    By Muphin in forum Game Programming
    Replies: 2
    Last Post: 09-10-2005, 11:52 AM
  4. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 10:50 AM
  5. Algorithm to walk through a maze.
    By Nutshell in forum C Programming
    Replies: 30
    Last Post: 01-21-2002, 01:54 AM