I passed in a char* into a function and I need to find out how many characters long it is..... how do i do this?
This is a discussion on Need Answer Quick within the C++ Programming forums, part of the General Programming Boards category; I passed in a char* into a function and I need to find out how many characters long it is..... ...
I passed in a char* into a function and I need to find out how many characters long it is..... how do i do this?
Code:int length=lstrlen(char *);
As long as you're 100% sure that there is memory allocated for the char* and it contains a '\0', then it should work.
Code:int function(char *x) { int length = strlen(x); return length; }