T
Tester Tester
hello every body.
I am working in address incrementation(+1) using c language.User
inputs a value which is in hex address and incremented by 1.
Suppose my address is - abc5:5723:2109:ffff:76af:82ea:9256:ffff.
So my output becomes - abc5:5723:2109:ffff:76af:82ea:9257:0000
I already parse the entire string and put it in 8 different array but
unable to do when the the last 4 digit reaches FFFF..I could not write
the logic of that last portion.can any body help me to solve the
problem?
My code is -
#include "stdafx.h"
#include "conio.h"
#include "stdio.h"
#include "string.h"
int _tmain(int argc, _TCHAR* argv[])
{
char address[] = "abc5:5723:2109:ffff:76af:82ea:9256:ffff";
printf("Your IPv6 address is ");
puts(address);
char a[10], b[10], c[10], d[10], e[10], f[10], g[10], h[10];
if(sscanf(address, "%10[^:]:%10[^:]:%10[^:]:%10[^:]:%10[^:]:
%10[^:]:%10[^:]:%10[^:]:",a,b,c,d,e,f,g,h)==8)
{
//puts(a);
//puts(b);
}
int m,n,o,p,q,r,s,t;
sscanf(a,"%x", &m);
sscanf(b,"%x", &n);
sscanf(c,"%x", &o);
sscanf(d,"%x", &p);
sscanf(e,"%x", &q);
sscanf(f,"%x", &r);
sscanf(g,"%x", &s);
sscanf(h,"%x", &t);
t++;
printf("The final output is %x:%x:%x:%x:%x:%x:%x:%x",m,n,o,p,q,r,s,t);
getch();
return 0;
}
Output -
You IPv6 address is abc5:5723:2109:ffff:76af:82ea:9256:ffff
The final output is abc5:5723:2109:ffff:76af:82ea:9256:10000
Waiting for your reply.
Ayanava
I am working in address incrementation(+1) using c language.User
inputs a value which is in hex address and incremented by 1.
Suppose my address is - abc5:5723:2109:ffff:76af:82ea:9256:ffff.
So my output becomes - abc5:5723:2109:ffff:76af:82ea:9257:0000
I already parse the entire string and put it in 8 different array but
unable to do when the the last 4 digit reaches FFFF..I could not write
the logic of that last portion.can any body help me to solve the
problem?
My code is -
#include "stdafx.h"
#include "conio.h"
#include "stdio.h"
#include "string.h"
int _tmain(int argc, _TCHAR* argv[])
{
char address[] = "abc5:5723:2109:ffff:76af:82ea:9256:ffff";
printf("Your IPv6 address is ");
puts(address);
char a[10], b[10], c[10], d[10], e[10], f[10], g[10], h[10];
if(sscanf(address, "%10[^:]:%10[^:]:%10[^:]:%10[^:]:%10[^:]:
%10[^:]:%10[^:]:%10[^:]:",a,b,c,d,e,f,g,h)==8)
{
//puts(a);
//puts(b);
}
int m,n,o,p,q,r,s,t;
sscanf(a,"%x", &m);
sscanf(b,"%x", &n);
sscanf(c,"%x", &o);
sscanf(d,"%x", &p);
sscanf(e,"%x", &q);
sscanf(f,"%x", &r);
sscanf(g,"%x", &s);
sscanf(h,"%x", &t);
t++;
printf("The final output is %x:%x:%x:%x:%x:%x:%x:%x",m,n,o,p,q,r,s,t);
getch();
return 0;
}
Output -
You IPv6 address is abc5:5723:2109:ffff:76af:82ea:9256:ffff
The final output is abc5:5723:2109:ffff:76af:82ea:9256:10000
Waiting for your reply.
Ayanava