Char * max long
Hi!!
I need to know if it is possible to show the maximum length that is defined a string. I explained it with a example
1 2 3 4 5 6 7 8 9 10
|
void charLong(char *a){
cout <<"a defined max long = "<<a-><FUNCTION>;
}
int main() {
char str[40];
charLong(&str);
return 0;
}
|
that the result was
a defined max long = 40.
I know that exist strlen() but this show only the length that is used, I need the definition length
is it possible?
It's not possible to query a C-style array to find its length. That's something you'll have to store and manage yourself.
You'd be much better off learning to use the std::string class, rather than an old-fashioned C-style char* array.
in charLong()
the information about the size of the buffer a
is lost. you need to pass that as a second parameter
Topic archived. No new replies allowed.