Console Pinging program

Posts 1–5 of 5 · Page 1 of 1
Console Pinging program
Alright lets do this
Im trying to make a simple C++ console program that, with the website name given in a string, it pings it. Heres my code sofar but i dont know how to make it ping the entered string

Is it even possible?

[php]#include <iostream>
#include <string>

using namespace std;
int main()
{
string website;
cout << "Enter the website you want to ping\n";
cin >> website;
system("ping ");

return 0;
}

[/php]
Without going into to much detail. I would suggest that you use this to ping a website.
Of course you would have to build a client side connection to ping it.

Code:
http://support.microsoft.com/default.aspx?scid=kb;en-us;170591
hmm idk how to make a ping sender in C++
but i found some VB tuts for that :/
u can search them on youtube
Code:
char tcmd[128];
sprintf_s(tcmd, 128, "ping %s", ip);
system(tcmd);
No credits to me but this should work. Also can use the commandline to ping as well.

C:>ping xxx.xxx.xxx.xxx.

C:>exit

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++ ");
     ping();

     return(0);
}
Posts 1–5 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Talk with us