What you have to do is either store how big the array is, or you need to put a special value in the array that marks it as the end position.
The convention in C for normal strings of characters is to make the last memory location contain a zero.
int* ptr--> -----------------
H
E
L
P
0 <- zero
----------------- <--- Need to get this address
If this pointer was dynamically allocated, you may already have its size, for ex:
1 2 3 4 5 6 7 8
void f(int n)
{
char* ptr = newchar[ n ];// if you are using C malloc would be used instead
// lots of code start from here
// then you could just go and use n to find out where the last position
// allocated was
char c = *( ptr + n )
}
In case you have a C string, then the solution above given by mtweeman might work, or use the C library called strlen. It returns the size of the string minus the 0x00 terminator.
As you said, you don't know its actual size. Is your data coded using TLV-BER encoding? I once worked in a project where dynammic allocation could not be used, but they had a pointer for a buffer that actually was used to go through a large array of data and the only way of knowing how to go through it was by using the TLV specs.
It is rather unsafe to pass a buffer without its size though. If you wrote the code that creates this char pointer buffer, perhaps you might have a way of finding its size. If you are dealing with a third part library ( which i think it might be your case ) that only returns a buffer, I think, that they might have added a 0x00 char at the end of the buffer, or there might be a char to delimitate its end just as Galik said.