For over the few months I've being trying to display LIST the of IPV4 Adresses in C++ programming , but unfotunately when I am going to compile the code it done properly but it shows nothing to me and error message generate please fix this problem you genius guy's...
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <stdlib.h>
#include <time.h>
#define MAX 30
#define TEMP 5
using namespace std;
void randomNumber_array(int *arr[]) {
int r=0;
srand(time(NULL));
for(int i=0;i<4;++i)
{
r=0+rand()%246;
*arr[i]=r;
}
}
void ipAdress_listGenrator(char *ip_str,int num) {
int i,j,temp=0,*a[TEMP],arr[TEMP];
char temp_str[TEMP];
for(i=0;i<num;++i)
{
for(j=0;j<4;++j)
{
a[i]=&arr[i];
}
randomNumber_array(a);
for(j=0;j<4;++j)
{
sprintf(temp_str,"%d",*a[j]);
if(i<3)
{
strcat(ip_str,temp_str);
strcat(ip_str,".");
} else {
strcat(ip_str,temp_str);
}
}
cout<<ip_str<<endl;
*ip_str='\0'; //clearing a string
}
}
int main() {
char ip_string[MAX]={'\0'};
unsigned long int n;
cout<<"Enter a number : "; cin>>n;
ipAdress_listGenrator(ip_string,n);
system("pause");
return 0;
}