Hey, I am having knowledge of C. And that is why I have tried it using c language. I think it will help you to get your logic for your solution:
Code:
#include <stdio.h>
#include <string.h>
#include<stdlib.h>
main()
{
int num = 1,z;
long Lnum,longnum2;
char ch[]=" 168.1.2.3";
char *string;
char str2[16];
printf("String: %s\n", str);
string = strtok(str, ".");
strcpy(str2,string);
while (1)
{
string = strtok(NULL, ".");
if (string == NULL)
{
exit(0);
}
strcat(str2,string);
Lnum=atol(str2);
printf("long integer is %ld \n",Lnum);
}
Bookmarks