Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Closed Thread
 
Thread Tools Display Modes
Old Sep 14th, 2006, 12:33 PM   #1
shadyi
Newbie
 
Join Date: Apr 2006
Posts: 20
Rep Power: 0 shadyi is an unknown quantity at this point
Exclamation performing a command in DOS using a c++ program

i want to write a program that does these commands for example

C:\cd Program Files
C:\cd..
shadyi is offline  
Old Sep 14th, 2006, 12:41 PM   #2
Mjordan2nd
The Supreme Ruler
 
Join Date: May 2004
Location: Houston
Posts: 1,476
Rep Power: 6 Mjordan2nd is on a distinguished road
The system() function should work, I believe.
__________________
"Every gun that is made, every warship launched, every rocket signifies, in the final sense, a theft from those who hunger and are not fed, from those who are cold and are not clothed. The world in arms is not spending money alone. It is spending the sweat of its laborers, the genius of its scientists, the hopes of its children." - Dwight D. Eisenhower
Mjordan2nd is offline  
Old Sep 14th, 2006, 12:51 PM   #3
shadyi
Newbie
 
Join Date: Apr 2006
Posts: 20
Rep Power: 0 shadyi is an unknown quantity at this point
didn't work for me
do i need to include something for it to work ?

EDIT:
system("");
that's it
i got it

but how do i open cmd first?
shadyi is offline  
Old Sep 14th, 2006, 1:06 PM   #4
v0id
Hobbyist Programmer
 
Join Date: Apr 2006
Posts: 155
Rep Power: 3 v0id is on a distinguished road
system() is in the library stdlib.
If I get this right you don't need to open a command line first.
#include <cstdlib>

// ...

system("Some command");
__________________
-- v0id
v0id is offline  
Old Sep 14th, 2006, 1:43 PM   #5
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Please consider reading the forum's rules/FAQ, a "How to Post a Question..." thread, and the documentation for the functions you use.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline  
Old Sep 15th, 2006, 3:57 AM   #6
bl00dninja
Programming Guru
 
bl00dninja's Avatar
 
Join Date: Oct 2004
Location: namespace std
Posts: 1,246
Rep Power: 6 bl00dninja is on a distinguished road
// Removed potentially harmful code
__________________
i put on my robe and wizard hat...

Have you ever heard of Plato, Aristotle, Socrates?...Morons.

Last edited by Mjordan2nd; Sep 15th, 2006 at 12:23 PM. Reason: Potentially harmful code
bl00dninja is offline  
Old Sep 15th, 2006, 8:37 AM   #7
badbasser98
Hobbyist Programmer
 
Join Date: Mar 2005
Location: United States
Posts: 124
Rep Power: 4 badbasser98 is on a distinguished road
Quote:
Originally Posted by bl00dninja View Post
// removed potentially harmful code
:banana:
__________________
Learning to use C++ and loving every minute of it.

Last edited by Mjordan2nd; Sep 15th, 2006 at 12:24 PM. Reason: Potentially harmful code
badbasser98 is offline  
Old Sep 15th, 2006, 8:54 AM   #8
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
The guy's a definite dink, but he's not THAT bad a dink. Blood's probably been into the beer, Basser, what's your excuse? You can't format the drive you're on under some OSes but what if he does it from or to another drive? I don't find it funny, and it COULD have legal implications on a technical forum.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers

Last edited by DaWei; Sep 15th, 2006 at 9:06 AM.
DaWei is offline  
Old Sep 15th, 2006, 10:13 AM   #9
Pizentios
Programming Guru
 
Pizentios's Avatar
 
Join Date: May 2004
Location: Brandon, Manitoba, Canada
Posts: 2,023
Rep Power: 7 Pizentios is on a distinguished road
Send a message via ICQ to Pizentios Send a message via MSN to Pizentios
I got to agree with DaWei, posting something like that in a thread where a new user (new to programming) is trying to learn is bad form. I know you guys ment it as a joke, but some users probably wouldn't see it that way, it could even cause problems on the users system.
__________________
Profanity is the one language that all programmers understand.

Check out my Blog <---updated Nov 30 2007!
Pizentios is offline  
Old Sep 15th, 2006, 10:30 AM   #10
peace_of_mind
Professional Programmer
 
peace_of_mind's Avatar
 
Join Date: Sep 2004
Location: Hell if I know most of the time
Posts: 439
Rep Power: 5 peace_of_mind is on a distinguished road
Send a message via MSN to peace_of_mind Send a message via Yahoo to peace_of_mind
For the most part I agree, but given this OP's track record I kinda like bl00dninja's idea.
__________________
Amateurs built the ark
Professionals built the Titanic

peace_of_mind is offline  
Closed Thread

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Language display in program Prm753 C++ 3 May 30th, 2006 6:45 PM
Help me program this with Watcom! DBZ Other Programming Languages 3 Feb 26th, 2006 10:41 PM
Creating a program to test a program sixstringartist C 8 Jan 21st, 2006 2:15 PM
Nonsense Name generator program chillster13 C 14 Jun 17th, 2005 3:05 AM
airport Log program using 3D linked List : problem reading from file gemini_shooter C++ 0 Mar 2nd, 2005 5:12 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 11:56 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC