470,864 Members | 1,723 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,864 developers. It's quick & easy.

how to find size of unsigned char* ??

Hey guyz if i wanna know how to find size of unsigned char*?

void func1(unsigned char* str)
int a;
////////////////now how to store size of str in a????

Mar 23 '08 #1
2 13153
9,208 Expert Mod 8TB
Either count the characters in str up to, but not including the \0, or pick up a C book and read up on the C library string functions.

I'll bet there's one in there that will do exactly what you want.
Mar 23 '08 #2
3,652 Expert 2GB
You can use the sizeof() operator, but that will return the size of the actual pointer. If you are using the unsigned char* to point to a character array, you cannot use sizeof(). You can use strlen(), which counts the number of characters before the terminating '\0' character (which you should make sure is present before using any built-in functions like this), or you can use an extra int parameter and pass in the size when the function is called.
Mar 23 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Harsha | last post: by
14 posts views Thread by Agoston Bejo | last post: by
5 posts views Thread by chellappa | last post: by
4 posts views Thread by cdrom205 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.