How can i have a program execute a comand from inside the c program. I know that i have to create a function?
How can i have a program execute a comand from inside the c program. I know that i have to create a function?
Be more specific man ...Okay u want to execute ur command prompt codes right ???Originally posted by Unregistered
How can i have a program execute a comand from inside the c program. I know that i have to create a function?
if( that is what u want)
system();/* this will help u out*/
else
printf ("???");
E.g: wanna dir the files from ur c program
system("dir"); /*Dirs the files*/
"I wish i could wish my wishs away"
"By indirections find directions out" -- William Shakespears
"Do what thou wilt shall be the whole of the law" -- Crowley "THE BEAST 666"
Mizra -> love = Death...
RDB(Rocks yooo)..
http://www.cbeginnersunited.com
Are you ready for the Trix ???
What is system()?? can't find documentation on it!!! and where and how do i use it?
Unregistered guy,
datainjector just got done saying you need to be more specific. You said you need to create a function. ok, that would have been my answer to the question of how do you execute a command in a program. so it is impossible to answer you unless you clarify what you are trying to do.
"You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter
There's a lot to be said for looking at the FAQ
Also....
Dont flame people just because they suggest you research your problem.Originally posted by FillYourBrain
#define FLAME(user) cout << user << " must die!" << endl;
FLAME("Troll_King")//for obvious reasons
FLAME("Salem")//for Googling people to death
but it's not a REAL flame, just a fun flame macro!
"You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter
I am willing to concede that Salem is not fully deserving of my FLAME macro. I suppose I can remove him soon. I was just in a mood that day and did not want to be googled. I'm better now
"You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter
And anyway.......use inline functions....not MacrosOriginally posted by FillYourBrain
I am willing to concede that Salem is not fully deserving of my FLAME macro. I suppose I can remove him soon. I was just in a mood that day and did not want to be googled. I'm better now
I know but an inline function would have taken up more signature space. picky ol' snot
be nice or I'll start using gotos
"You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter
>How can i have a program execute a comand from inside the c program. I know that i have to create a function?
The system function is a standard way to do this, but it's behavior is system-dependent. It's simple enough to use without creating your own function, but if you must then you can do something like this:
As stated in the code, the return value for system depends on your compiler, be careful how you handle those values because it will make your program non-portable if you aren't careful. Of course, you can simply ignore the return value.Code:int execCommand ( const char *command ) { /* ** system returns an implementation-defined value. */ return system ( command ); }
-Prelude
My best code is written with the delete key.