is there a way i can do a system command (if thats wut u call it) in c++ something lke
cout << "net send * messsage";
and if so how would i do it without having to display it in the dos windows with the cout?
This is a discussion on running system commands?? within the C++ Programming forums, part of the General Programming Boards category; is there a way i can do a system command (if thats wut u call it) in c++ something lke ...
is there a way i can do a system command (if thats wut u call it) in c++ something lke
cout << "net send * messsage";
and if so how would i do it without having to display it in the dos windows with the cout?
It's in the FAQ. Option 1, i.e. the system command would likely do what you want.
I used to be an adventurer like you... then I took an arrow to the knee.
Here's what I did. Take a look.
Code:// MeGaBite1's Net Send App v0.1 #include <iostream> #include <sstream> #include <string.h> using namespace std; int main(void) { int nummsg; int n = 0; std::stringstream stream; char ipaddr[20]; char msg[200]; cout << "MeGaBiTe1's Net Send App v0.1\n"; cout << "Enter Computer Name or IP:\n "; cin >> ipaddr; cout << "Enter Message:\n "; cin.getline (msg,200); cin.getline (msg,200); cout << "Enter Number of Messages to be Sent:\n "; cin >> nummsg; stream << "net send " << ipaddr << ' ' << msg; system ("PAUSE"); while (n < nummsg) { std::system(stream.str().c_str()); n++; } system ("PAUSE"); return 0; }
Last edited by MeGaBiTe1; 08-30-2004 at 05:40 PM.
so which command is the system one cause you jst gave me a program and i cant exactly tell
It's the one that says, "system". Do you know C++?
the answer is pretty obviousOriginally Posted by sean_mackrory
![]()
some entropy with that sink? entropysink.com
there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka
so which answer is the obvious one cause you jst gave me a sentence and i cant exactly tell
i belive theshould be clue enough
![]()
some entropy with that sink? entropysink.com
there are two cardinal sins from which all others spring: Impatience and Laziness. - franz kafka
Umm.... I'll google it....
im not very good at c++ yet and how am i supposed to know that answer thats y i asked (sean), i didn't ask for a whole program either (even though it was small)
if its the system command why is there a stream next to the commands then aCode:stream << "net send " << ipaddr << ' ' << msg; system ("PAUSE"); while (n < nummsg) { std::system(stream.str().c_str()); n++; } system ("PAUSE");
system ("PAUSE") thing, i assume its stream but i have no idea wut the system ("{AUSE") is?
A forum is not a good medium for teaching the basics of object oriented programming. To send a command to the system, place the command in a C-style string and place either the string literal or a pointer to the first element of the array in parenthese next to the word system, and be sure to include cstdlib.
i dont really get wut you mean, could you just answer my question cause i still dont know the syntax of it or wut some of the other stuff in the net send program was
can anyone help me???
>can anyone help me???
From what I can tell, you're beyond help. system is a function, you give it a C-style string containing the system command you want processed as an argument. For example, if I wanted to use the DOS pause command I would do this:
If I wanted to do a tracert for cprogramming.com I would do this:Code:#include <cstdlib> ... std::system ( "pause" );
If that's too much for you then you need to go back to the beginning and study functions. Otherwise you'll just end up being frustrated.Code:std::system ( "tracert www.cprogramming.com" );
My best code is written with the delete key.