Imported from the Apple Support Forums via the Wayback Machine 🔗
Bytes is a just pointer. You will have to use the "usedLength" parameter to get the size because the result is not null terminated.
0
abuharsky·
Imported from the Apple Support Forums via the Wayback Machine 🔗
Does C contain function for automatic calculation size or I need do it personally?
When I can use "sizeof" to calculate amount of data in bytes, or it only for strings(because they ended by '')?
0
etresoft·
Imported from the Apple Support Forums via the Wayback Machine 🔗
abuharsky wrote:
Does C contain function for automatic calculation size
Yes. The is what sizeof() is. But it only works on POD (Plain Old Data). It will tell you the size of short, int, pointer, any struct, but it won't look into a structure and tell you how much memory is used in a particular buffer.
or I need do it personally?
There is nothing you can do in this case.
When I can use "sizeof" to calculate amount of data in bytes, or it only for strings(because they ended by '')?
If this were a string (which it isn't) you could use strlen() to get its size. The NSString getBytes:... message does not return a string. It fills a previously allocated buffer. How much data it puts there is returned in "usedLength". That is the only way for you to tell how many bytes were written into your buffer.
0
abuharsky·
Imported from the Apple Support Forums via the Wayback Machine 🔗