Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.
DOS commands in C
Name: mr_cheese Date: February 7, 2004 at 05:58:29 Pacific OS: XP CPU/Ram: 2.6
Comment:
can one run DOS commands using c++. if so whats the command.
Name: SN Date: February 7, 2004 at 08:58:19 Pacific
Reply:
I'm not sure I remember from my C++ days (which are quickly coming back to haunt me since my operating systems class is all C...), but do you need to escape the slash?
c:\\mydir
This question is asked so often that even I have memorized the answer. I would place it at number 3 or 4 in the top 5 questions. 1. Which language should I learn 2. How do I get HTML forms to e-mail to me 3. modify registry with batch 4. use dos commands in C(++) 5. How can I become more like SN?
-SN
0
Response Number 3
Name: mr_cheese Date: February 7, 2004 at 12:29:33 Pacific
Reply:
i try typing the following but seem to get errors when compiling, im new to C, so if the code is not correct what should i be typing??
Name: SN Date: February 7, 2004 at 12:44:21 Pacific
Reply:
First off...Always tell us what errors you get when compiling. In this case, a competent C programmer can tell what a few of the errors are without you telling the errors, but it's still polite.
Your system() function should actually be called main...I'm not sure of the exact syntax but it's something like #include <stdlib.h> #include <process.h>
int main() { system("echo hello") }
-SN
0
Response Number 5
Name: Fozzie Date: February 7, 2004 at 20:01:27 Pacific
Reply:
It has been a while hasn't it? ;)
Try:
#include <stdlib.h> #include <process.h>
int main() { system("echo hello"); return 0; }
0
Response Number 6
Name: mr_cheese Date: February 8, 2004 at 02:41:05 Pacific
Summary: ok guys, here is a question i have for you, if i want to execute dos commands in c++, what would i use? i'd really appreciate if you could answer this question, as batch files don't do everything i ne...