473,395 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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;
a=??
////////////////now how to store size of str in a????


}
Mar 23 '08 #1
2 15733
weaknessforcats
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
Ganon11
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

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

Similar topics

1
by: Harsha | last post by:
I have been working on VB, ASP for quite a long time. Very Recently ( From past 1 month) I am managing a VC++ project. I am trying to use the code which i downloaded from the internet to find the...
14
by: Agoston Bejo | last post by:
Hi, sorry about the multiple posting, technical difficulties.... ----- What does exactly the size of the int datatype depends in C++? Recenlty I've heard that it depends on the machine's...
5
by: chellappa | last post by:
Hi All, How to find the data type of the variable ? is there any libaray function avaiable? Because i want create generic data type of some operation . Thanks All By Chellappa
4
by: cdrom205 | last post by:
static void MDString ( unsigned char *input) { MD5_CTX context; unsigned char digest; unsigned int len = sizeof(input);//strlen (const char*) md5.MD5Init (&context); md5.MD5Update...
11
by: C C++ C++ | last post by:
Hi all, got this interview question please respond. How can you quickly find the number of elements stored in a a) static array b) dynamic array ? Rgrds MA
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.