Thread: ping in c++
View Single Post
  #9 (permalink)  
Old November 19th, 2007, 02:38 PM
cisso cisso is offline
Registered User
 
Join Date: Nov 2007
Location: São Paulo, SP, Brazil.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to cisso
Default

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.
Reply With Quote