• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Long to C-String
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

  • Prev by Date: Re: Transferring Projects to new Computer
  • Next by Date: Re: Long to C-String
  • Previous by thread: Long to C-String
  • Next by thread: Re: Long to C-String
  • Index(es):
    • Date
    • Thread