Re: Long to C-String
Re: Long to C-String
- Subject: Re: Long to C-String
- From: email@hidden
- Date: Mon, 07 Apr 2003 15:18:10 -0700 (PDT)
you could use the ltoa() function in <stdlib.h> as follows:
ltoa( bytesPtr, buffer, 10 );
or the following code:
char *str = new char[sizeof(long)];
int index = sizeof(str);
int remainder;
while( bytesPtr != 0 )
{
remainder = bytesPtr % 10;
str[--index] = 30 + remainder;
bytesPtr = bytesPtr / 10;
}
Zameer
On Mon, 07 Apr 2003 15:09:25 -0700 (PDT), David Blanton wrote:
>
>
Given :
>
>
NSData * theData;
>
...
>
bytesPtr = [theData bytes];
>
>
Where bytesPtr points to 00000001
>
>
How can this converted to its C string representation (0x31)?
>
>
Thanks.
>
>
David Blanton
>
"Cocoa FNG"
>
_______________________________________________
>
cocoa-dev mailing list | email@hidden
>
Help/Unsubscribe/Archives: <a
href="
http://mail.canada.com/jump/http://www.lists.apple.com/mailman/listinfo/cocoa-dev">
http://www.lists.apple.com/mailman/listinfo/cocoa-dev</a>
>
Do not post admin requests to the list. They will be ignored.
__________________________________________________________
Get your FREE personalized e-mail at
http://www.canada.com
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.