Oct 10, 2015 at 1:20pm UTC
How can i make a function that open cmd.exe with something in it?
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
system("Start cmd.exe");
return 0;
}
Last edited on Oct 10, 2015 at 1:22pm UTC
Oct 10, 2015 at 1:26pm UTC
What do you mean "with something in it"?
Oct 10, 2015 at 1:28pm UTC
After i run it and cmd.exe is opened there i want to be already written something.
Last edited on Oct 10, 2015 at 1:31pm UTC
Oct 10, 2015 at 1:34pm UTC
Be more specific - do you want the user to be able to backspace whatever is written?
Oct 10, 2015 at 1:34pm UTC
add razzvan_2000 at skype and talk there
Oct 10, 2015 at 1:47pm UTC
Sorry, I only give help in public.
Oct 10, 2015 at 1:49pm UTC
Wait ~20 and i explain better
Oct 10, 2015 at 2:07pm UTC
When i run the program i want to open 2 cmds 1 from codeblocks and 1 from pc and in cmd from pc i want to be already written something like "Troll". Because i want to troll my friend and i know to make a loop but i don't know how to make to open the cmd where is written "troll".
Oct 10, 2015 at 2:22pm UTC
Again: do you want the user to be able to backspace whatever is written?
There are multiple ways to do what you are trying to do. C++ is not one of the ways I would recommend.
The cmd.exe program has built-in support for what you want to do - try running help cmd
Last edited on Oct 10, 2015 at 2:28pm UTC
Oct 10, 2015 at 2:25pm UTC
I don't want the user to be able to backspace whatever is writte.
Oct 10, 2015 at 2:28pm UTC
Maybe you just want to run cmd /K "echo message"
?
Oct 10, 2015 at 2:30pm UTC
Can you edit this to work?
#include <iostream>
#include <windows.h>
using namespace std;
int main()
{
system("Start cmd.exe");
return 0;
}
Oct 10, 2015 at 2:40pm UTC
I literally just showed you how to do that, are you so lazy that you cannot even change 12 characters?
Oct 10, 2015 at 2:42pm UTC
Man i changed but when i run it doesn't happened nothing or how can i make it like cout and just to press enter
Oct 10, 2015 at 2:49pm UTC
I don't know what you mean, it works for me. Again, why do you want to do this with C++? C++ is not the correct language for this.
Oct 10, 2015 at 2:52pm UTC
It's like you open the cmd then press enter and something is doing that's what i want to do in c++
Oct 10, 2015 at 2:53pm UTC
I already showed you the code required to make that happen, and I tested it myself - it works. You still have not answered: why C++?