#include <iostream>
#include <stdio.h>
#include <string>
#include <stdlib.h>
#include <time.h>
using namespace std;
char* ipgen();
char* ipgen(){
char buffer[50];
int oct1; // octet 1 of the random ip
int oct2; // octet 2 of the random ip
int oct3; // octet 3 of the random ip
int oct4; // octet 4 of the random ip
oct1 =rand() % 254 + 1;// random octet 1
oct2 =rand() % 254 + 1;// random octet 2
oct3 =rand() % 254 + 1;// random octet 3
oct4 =rand() % 254 + 1;// random octet 4
sprintf(buffer,"%d.%d.%d.%d \n",oct1,oct2,oct3,oct4);
return(buffer);
}
int main ()
{
cout << ipgen();
return(0);
thanks in advance - arkwind

New Topic/Question
Reply



MultiQuote






|