C++ ProgrammingGeneral discussions for the C++ language. For questions specific to Microsoft's Visual C++ variant, see the Visual C++ forum instead.
Welcome to the p2p.wrox.com Forums.
You are currently viewing the C++ Programming section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
Maybe his computer is doing more ... i.e. a portscanner that pings first? That's what I do, 'cause it's way easier to write a program that opens ports in a tight loop than to muck with ICMP from C/C++. If anybody knows an easy/portable way to muck with ICMP in C/C++ though, i'd be intrested in knowing it/seeing links. I readily accnowledge that my solution is more of a cop-out because I'm too lazy to write a lot of code.
quote:Originally posted by bmagness
There isn't one function you can call. I suggest that you use ICMP to ping. Go to www.msdn.com and search on ICMP. This link might work:
But, how can I draw this output from the window for use in my program? I need to know if the computer is active or not since I am digging for files. Should I put all of the output from the pink result into a text file and then search it for target information? And if so, how? I keep hearing about piping or something along those lines, but I just want some simple way to just retrieve that output without having to break a leg over a pile of excess code.
Hi, i've tryed to put this code to run but it didn't compile.
my compiler didn't recognize the headers without .h , the "static strings" global declared and the "using namespace std". What compiler have you used?
Quote:
quote:Originally posted by TotcoS
Here you go..
Code:
#include <iostream>
#include <string>
#include <windows.h>
using namespace std;
static string host;
static string ping_again;
void ping()
{
system("cls");
cout << "Host: ";
cin >> host;
system (("ping " + host).c_str());
cout << endl;
cout << "(Y)es or (N)o\n\n";
cout << "Ping another host: ";
cin >> ping_again;
if (ping_again == "Y" || ping_again == "y")
{
system("cls");
ping();
}
else if (ping_again == "N" || ping_again == "n")
{
system("exit");
}
}
int main()
{
SetConsoleTitle("Ping in C++ by TotcoS");
ping();
return(0);
}
Happy Coding,
Scott Stauffer aka TotcoS of BlackHat-Forums.