I have a chunk of binary data which contains structures with offsets and then strings; in C++ it is easy:
struct foo
{
int offset;
char * s;
}
void * data;
... data is read and set
foo * header = (foo*) data;
header->s = (int)header-> + (int)data;
int len = strlen(header->s);
char* ns = new char[len+1];
strcpy(ns,header->s);
simple enough... in C# how would you do this? The biggest problem is that I don't know the length of the string. It is null terminated.
I have the data in a byte[]
and an IntPtr to the memory but I need a POINTER to that data a a string (char *
) something that I can get the length of the string.