Re: [Dev-C++] initializing string with memory buffer
Open Source C & C++ IDE for Windows
Brought to you by:
claplace
From: Lloyd <ll...@cd...> - 2008-09-15 21:04:28
|
I think my explanation was not clear.I was not talking about the memory representation of "1.2.3.4", but how the system will store IP. The system stores an IP address in 4bytes.(As in IPv4 header). I want to make the string representation of this 4bytes. Think now I made it clear. Thanks, Lloyd On Mon, 2008-09-15 at 22:20 +0200, Per Westermark wrote: > That is not a string. > > A string representation of the IP number should have "1.2.3.4" or in > binary: > 0x31 > 0x2e > 0x32 > 0x2e > 0x33 > 0x2e > 0x34 > 0x00 > > /pwm > > On Mon, 15 Sep 2008, Lloyd wrote: > > > Hi, > > > > I am using C++ STL string. I have an IP address something like 1.2.3.4 > > So its memory will be 0x01020304. I want to initialise a string with > > this memory. How can I do this? > > > > > > > > int ip=0x01020304; > > string s(<I dont know how to fill this area>); > > > > so that > > > > s[0]=0x01; > > s[1]=0x02; > > s[2]=0x03; > > s[3]=0x04; > > > > Thanks, > > Lloyd > > > > > > > > > > ______________________________________ > > Scanned and protected by Email scanner > > > > ------------------------------------------------------------------------- > > This SF.Net email is sponsored by the Moblin Your Move Developer's challenge > > Build the coolest Linux based applications with Moblin SDK & win great prizes > > Grand prize is a trip for two to an Open Source event anywhere in the world > > http://moblin-contest.org/redirect.php?banner_id=100&url=/ > > _______________________________________________ > > Dev-cpp-users mailing list > > Dev...@li... > > TO UNSUBSCRIBE: http://www23.brinkster.com/noicys/devcpp/ub.htm > > https://lists.sourceforge.net/lists/listinfo/dev-cpp-users > > ______________________________________ Scanned and protected by Email scanner |