PW> I tried to automatically determine the maximum string length by using :
PW> int Max_Length = sizeof(String) / sizeof(char);
BTW, as far as I'm aware, you're meant to go "sizeof String" for
a variable, and "sizeof(char)" for a data type.
PW> int Max_Length = sizeof(String);
PW> is supposed to be in a function that is called and passed a char * to
PW> String, which (I am told) will then make Max_Length the sizeof() a char *
PW> !!!
PW> That is correct -- I am getting 2, not 100. How do I get the correct
PW> length with just a char * ???
The short story is you can't, because the function may be external, and how
did you expect the compiler to magically know the length? It can only know
the length if you give it that information, either as an extra parameter,
or padding the variable out so you can do a strlen(), or specify the size
in the prototype, or use a #define, or use a STRING structure of your own,
that contains both a length and a character pointer. BFN. Paul.
@EOT:
---
* Origin: X (3:711/934.9)
|