c++ system() function

Hello.i am back with a new "issue".i searched the internet about it but not weary much.(or maybe i did not searched correctly).
So the thing is i want to make some simple things:change directory to a certain file,open a file here,rename a file there.things like that.and from what i read u need some things like this:
1
2
3
4
system("cd .. && DIR");
Separate each command with the & symbol
Use a && to ensure that the following command 
is only run if the previous was successful


Now for example if y write:system("notepad"); it will open my notepad.So how does it work? u just put some commands that are like standard in quotes?(like exit,fdisk,runas,regini,xcpoy).
they work in command prompt,but.....
i would appreciate the help.TY
it will open my notepad.So how does it work? u just put some commands that are like standard in quotes?

I'm not sure about what your asking, could you rephrase that please?
What system() does is runs that command on the command line. "notepad" is that name of a program that is in the PATH variable (probably) so it runs it.
aha..so if i want to open a file for example how do i write?.just like in cmd?..cd\..things like that?.can you give me an example.
I wouldn't use system(). I'd use the more system specific commands which are IMO safer and faster. But to answer your question, yes.

system():
http://www.cplusplus.com/reference/clibrary/cstdlib/system/

Why it's evil:
http://www.cplusplus.com/forum/articles/11153/

For most UNIX-likes:
http://www.opengroup.org/onlinepubs/009695399/functions/exec.html

For Windows:
http://msdn.microsoft.com/en-us/library/bb762153(VS.85).aspx

-Albatross
ok..ty.i will read more about it and it's behavior in different situations, try different things.and..i am not that interested on the speed that my program is running.
Last edited on
Topic archived. No new replies allowed.