Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

c++ var length 1

Status
Not open for further replies.

jimjake

Technical User
Oct 30, 2004
25
US
Hi . new to C++
have a var. that is called password, password could contain 1-10 char. I would like to find out how many char's password contains
 
Try the function strlen.

length = strlen(password);
should do it.
 
More better use STL string class from <string>:
Code:
#include <string>
...
string psw;
...
... psw.length()...
 
I like to use the CString class since the variables cannot overflow the allocated memory. Over the last twenty years, I have exceeded the defined length of a variable way too many times.

CString also has a function for obtaining the length of the string.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top