This is a problem where you have to enter a number having non zero digits and the program will convert it into a IP address having 4 parts and each part less than 255, and have to print all the IP addresses.
I have tried this recursive method and am running into an infinite loop.
#include<stdio.h>
#include<math.h>
int a[3];
void comuni(unsigned long n,int count){
int i=count;
do{
if(count<0){
return;
}
int t=pow(10,i);
a[count]=n/t;
int rem=n%t;
if(a[count]<=255 &&a[count]>0 && count>=0){
printf("%d.",a[count]);
comuni(rem,count-1);
}
i++;
}while(1);
}
int main()
{
// Insert your code here.
unsigned long n;
scanf("%ul",&n);
comuni(n,3);
return 0;
}