开发者

how to get the bytes count of unsigned char datatype in iphonesdk

开发者 https://www.devze.com 2023-03-05 12:46 出处:网络
Wrote below code... How can i get the count of by开发者_高级运维tes in bytePtr variable. unsigned char *bytePtr = (unsigned char *)[imageData bytes];

Wrote below code... How can i get the count of by开发者_高级运维tes in bytePtr variable.

unsigned char *bytePtr = (unsigned char *)[imageData bytes];

Thanks.....in advance


the number of bytes is given by [ imageData length ]


See the Documentation for NSDate ,

where length return the "The number of bytes contained in the receiver."

- (NSUInteger)length

So use

int numberOFByte = [ imageData length ];


either use strlen(bytePtr); or use [imageData length];

Edited on the request of to Mr. Jeremy as he suggested. But I want to add more on that, it might not be terminated by the NULL but data may contain 0 value which will act as a null terminator so the string after that is not counted, So it's a Bad idea. use [imageData length];

0

精彩评论

暂无评论...
验证码 换一张
取 消