Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #1063 > unrolled thread
| Started by | Tester Tester <codectest99@gmail.com> |
|---|---|
| First post | 2011-11-30 05:11 -0800 |
| Last post | 2011-11-30 16:51 +0000 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.programming
Incrementing IPv6 address Tester Tester <codectest99@gmail.com> - 2011-11-30 05:11 -0800
Re: Incrementing IPv6 address Willem <willem@toad.stack.nl> - 2011-11-30 13:44 +0000
Re: Incrementing IPv6 address Ben Bacarisse <ben.usenet@bsb.me.uk> - 2011-11-30 16:51 +0000
| From | Tester Tester <codectest99@gmail.com> |
|---|---|
| Date | 2011-11-30 05:11 -0800 |
| Subject | Incrementing IPv6 address |
| Message-ID | <65c6afc7-ed5a-4372-8953-f3270a11f4ba@y6g2000yqe.googlegroups.com> |
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
[toc] | [next] | [standalone]
| From | Willem <willem@toad.stack.nl> |
|---|---|
| Date | 2011-11-30 13:44 +0000 |
| Message-ID | <slrnjdccpg.2or6.willem@toad.stack.nl> |
| In reply to | #1063 |
Tester Tester wrote:
) 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?
Can you describe, in plain old English, what's supposed to happen when
a set of digits that is 0xffff is increased ?
So basically, when it's not 0xffff, it's increased by 1, and when
it *is* 0xffff, then what should happen ?
SaSW, Willem
--
Disclaimer: I am in no way responsible for any of the statements
made in the above text. For all I know I might be
drugged or something..
No I'm not paranoid. You all think I'm paranoid, don't you !
#EOT
[toc] | [prev] | [next] | [standalone]
| From | Ben Bacarisse <ben.usenet@bsb.me.uk> |
|---|---|
| Date | 2011-11-30 16:51 +0000 |
| Message-ID | <0.82baadc4c7677ac6b1b1.20111130165124GMT.87ipm1pn8z.fsf@bsb.me.uk> |
| In reply to | #1063 |
Tester Tester <codectest99@gmail.com> writes: > I am working in address incrementation(+1) using c language.User > inputs a value which is in hex address and incremented by 1. You multi-posted. This is rarely a good idea. When a post is relevant to more that one group (and you wish to post to them all) then cross posting is the preferred method. To see why, imagine someone here spending time answering you with all the same points I made in comp.lang.c simply because they don't happen to read both groups. <snip> -- Ben.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.programming
csiph-web