length of a string containing binary data

I have a BYTE *str;
In this BYTE string I am storing binary data which may contain many null terminating characters.
Functions like strlen and sysstringlen return the length of the string till the first found null terminating character.
I want to find the entire length of the string.
How do I do that????

I am not using win32 APIs.
I am using COM language.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ashwiniAuthor Commented:
Edited text of question.
0x0 is standart end of string. But becouse you  string contains many string(array of strings), you must set
some symbol/symbols as you oun end of string;
For example: say  EOS = '\n'
In this case you can use code:
for (int len = 0;  str[len] != EOS; len++);
In end len-> you lenght of string

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ashwiniAuthor Commented:
If the string data is coming from some other way,say from a dtatabase,then how do I go to the end of the data string and append a EOS character.

The problem is that how do I know that the binary data is ending at a particular position in the string.
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

ashwiniAuthor Commented:
Can I know how many bytes are dynamically allocated to the BYTE *str in which the binary data is stored????????
How do you dynamically allocate BYTE *str?
ashwiniAuthor Commented:
What I want to do is that somehow I want to strore this data coming from a database in a BYTE * variable.For this I first want to know the length of the data coming to me and accordingly strore it in the variable.After this I want to store the length in a different variable and send it to some other method.

ashwiniAuthor Commented:
The data coming to me can be less than or equal to 60000 bytes.
How is the data coming from a database?
ashwiniAuthor Commented:
The data comes through a socket.
If there data is Variable Lenght format, they have standart
structure: Len (usually 2 b), Data (Len baits).
ashwiniAuthor Commented:
Sorry, ashwini, what means "Yes"? Is my reply right?
(in this case you must accept reply) or something else?
ashwiniAuthor Commented:

Can you please clarify your answer.
A small piece of code would suffice.

I didn't get what you replied.

If i uderstand right, you want clarify reply about
Variable Lenght Format?
Well, records of such form can be builded in structure:
Len (2 b usually), text. Can be some variants:
For example, record can be from some fields.
In such case will number of fields,
and in Loop by number of fields : len of field, field.
All this depends of database, that you work with.
Example of code for 2-nd case
char *buff;  //input buffer
short nNumFields;//number of fields
memcpy(&nNumFields, buff,2);
char *ptr = buff+2;
char *MyString;//result
for (int i = 0; i < nNumFields; i++)
    short nLen;
    memcmp(nLen, ptr,2); ptr += 2;
    strncpy(MyString, ptr,nLen);
    ptr += nLen;
I hope(to 50%), that it helps. )-:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.