Problem with cin >>

I am writing a UDP flooder program in an attempt to get better with socket programming. Everything has gone well so far except for some reason this piece of code:

"int Packets;
cin >> Packets;"

is skipped when I run the program.
I have also tried using getline(cin, Packets) but for some reason my compiler fails to recognize it.
I am using Microsoft Visual C++ 2010 express

Please help.

Here is the full source code:

#include "stdafx.h"
#include <sys/types.h>
#include <winsock2.h>
#include <iostream>
#include <string>
#include <string.h>
#include <istream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
int OutSocket;
OutSocket = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); // define a socket and get its address
cout << "Please enter the IP address of the target: ";

sockaddr_in ForeignAddress; // define an address structure
cin >> ForeignAddress.sin_addr.S_un.S_addr; // get the ip address from the user

//cout << "Please enter the port you want to attack: ";
//cin >> ForeignAddress.sin_port; // get the port from the user

ForeignAddress.sin_port = 80;
ForeignAddress.sin_family = AF_INET; //set the family (this value is almost always the same)

sockaddr *AddressPointer; // define a pointer to the address struct
AddressPointer = (sockaddr*)&ForeignAddress; // cast the sockaddr_in as a sockaddr pointer (this is necessary to please the sento function)



char * BufferPTR = new char [5]; // buffer to send

BufferPTR = "hello"; //set the buffer contents

int ForeignAddressLength;
ForeignAddressLength = sizeof(ForeignAddress.sin_addr.S_un.S_addr);

cout << "please enter the number of packets you would like to send: ";
int Packets;
cin >> Packets;


int iteration = 0;

while (iteration <= NumSent) {
sendto(OutSocket, BufferPTR, 5, 1, AddressPointer, ForeignAddressLength);
iteration ++;
}

cout << "The attack was executed successefully\n";



}
Topic archived. No new replies allowed.