开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜