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 ...
- 03-26-2008 #1Just 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
- 03-26-2008 #2
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:
If man pages are not installed on your system, google this:Code:man 3 system
Hope this helps.Code:man system linux
--
Bill
Old age and treachery will overcome youth and skill.
- 03-27-2008 #3
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
- 03-27-2008 #4
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 :
Though gives the required output-If you use system call other than system() - like readdir() will get to know more and more about linux internalsCode:main(){ system("/bin/ls"); }
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
-------------------


Reply With Quote