Find the answer to your Linux question:
Results 1 to 4 of 4
Yo! I'm practicing my skills in C++ and thought of a thing that I can use in my education of programming too(I'm just a student :P). As I can always ...
  1. #1
    Just Joined!
    Join Date
    Mar 2008
    Posts
    1

    Return value of system()

    Yo!

    I'm practicing my skills in C++ and thought of a thing that I can use in my education of programming too(I'm just a student :P). As I can always add more stuff to it.
    I'd like to create a mini-version of GNOME starting out with a terminal.

    But well anyway, I'd like to know what the return value of system() is? If it's a string or if it's a int value or whatever it now is.

    And if you know a better way to do this than to use system(), then please let me know

  2. #2
    Linux Engineer wje_lf's Avatar
    Join Date
    Sep 2007
    Location
    Mariposa
    Posts
    1,192
    Oy!

    If you're a student, and you're learning C++, I'm hoping your instructor has told you about man pages. They're your first stop when learning about library functions in C or C++.

    To learn about man()'s return value, do this at the command line:
    Code:
    man 3 system
    If man pages are not installed on your system, google this:
    Code:
    man system linux
    Hope this helps.
    --
    Bill

    Old age and treachery will overcome youth and skill.

  3. #3
    Trusted Penguin Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,230
    I'm curious what you're intending to use system() for. system() can be used for many things, but for most things, you will want to use something else. popen() can be used if you want to read output from a command (or send input to it), and a fork()/exec() can be used to execute things in a somewhat more controlled way.
    DISTRO=Arch
    Registered Linux User #388732

  4. #4
    Linux Guru Lakshmipathi's Avatar
    Join Date
    Sep 2006
    Location
    3rd rock from sun - Often seen near moon
    Posts
    1,568
    Hi -
    IMHO,i think we should try to avoid using system() as far as we can- because with system() sys.call you can execute only shell commands.Remember system() is powerful function.
    For example - To display a directory content you need simple program like this :
    Code:
    main(){
    system("/bin/ls");
    }
    Though gives the required output-If you use system call other than system() - like readdir() will get to know more and more about linux internals
    I always perfer the second method - but sometimes i use system() too
    - Lakshmipathi.G
    -------------------
    FOSS India Award winning ext3fs Undelete tool and tutorials www.giis.co.in
    First they criticize you,Then they laugh at you,Then they fight with you,Then you win. - M.K.Gandhi
    -------------------

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
...