DingleBerries Posted March 7, 2009 Share Posted March 7, 2009 Ok I know this is horrible but i cant remember how to run dos commands in a string. Ive already looked and all I get are "use system()", but i cant. lol i got it.. #include <string> Quote Link to comment Share on other sites More sharing options...
Jonnycake Posted March 7, 2009 Share Posted March 7, 2009 C++? #include <iostream> using namespace std; int main() { string cmd; cin << cmd; system(cmd); return 0; } You mean like that? Edit: BTW, C++ isn't my language so I don't know if that will work Nah, it doesn't, try this: #include <iostream> #include <cstdio> #define CMDMAXLEN 250 using namespace std; int main() { int x=0; char ch; char cmd[CMDMAXLEN+1]; bzero(&cmd,CMDMAXLEN+1); ch=getchar(); while(ch!='\n') { if(x<CMDMAXLEN) { cmd[x]=ch; x++; } ch=getchar(); } system(cmd); return 0; } Just used some C in it :D Quote Link to comment Share on other sites More sharing options...
DingleBerries Posted March 7, 2009 Author Share Posted March 7, 2009 Hey, thanks for the reply but i was right all along... just left out a header :P, too little sleep. I knew all my code was right but it just wouldnt compile. left out string.h Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.