Welcome to HBH! If you have tried to register and didn't get a verification email, please using the following link to resend the verification email.

C++ pinger coding... help please


lukem_95's Avatar
Member
0 0

ok im pretty new to programming in C++, but i thought i was doing pretty well, iv had the sams learn c++ in 24 hours book for a couple of months but only just started learning it, i tried to build a pinger however ran into some errors, my compiler simply says:

Error: Unresolved external '_main' reference from C:\CBUILDERX\LIB\COX32.OBJ

ILINK32 exited with error code: 2 Build Canceled due to errors

I think this has something to do with my compiler but im not sure, so i will post my C++ incase something is the matter with that.

Please help, im keen to learn the language as so far i can only really code web languages.

#include<iostream>
#include<windows.h>
#include<dos.h>

using namespace std;

int Main()
{
  start:

  char tarUrl;
  int tarPing;
  int counter;

  system("title Pinger");
  cout << "Please enter the website you wish to ping (e.g. google.com): ";
  cin >> tarUrl;
  cout << "\n\n Thankyou, how many times would you like to ping ";
  cout << tarUrl;
  cout << "?:";
  cin >> tarPing;
  cout << "\n\n Starting to ping...";

  counter = 0;

  if(counter < tarPing)
  {
    system("ping "+tarUrl);
    counter++;
    cout << "Pinged ";
    cout << tarUrl;
    cout << counter;
    cout << " times!";
    system("cls");
  } else {
    cout << "Pinging Completed! Pinged ";
    cout << tarUrl;
    cout << " ";
    cout << counter;
    cout << " times!";
  }

  cin.get();
  goto start;
}

EDIT: like i said i know the code is n00by, please dont flame me on my use of system commands etc, as i dont know any other code to use, if you want to suggest any i would appreaciate that.


ghost's Avatar
0 0

markupint main() Not markupint Main()


lukem_95's Avatar
Member
0 0

ah thankyou, that sorted it out, tysm