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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

determing the length of a string

Status
Not open for further replies.

tougo

Technical User
Sep 9, 2002
27
GB
how can i determine the length of characters used in a sting?
for a example the string "i like tea" has 10 characters (including the blank ones)and after getting the length of the string to make each string 15 character long adding a single character until reaching the desired length
for example "i like tea" to become "i like teaOOOOO"

the strings are in textboxes

(ok i know it's sounds completely silly)
 
If it's a c style string (ie. char*) then use the strlen() function:[tt]

char str[100] = "hello";
int length = strlen(str);[/tt]

If you're using MFC and CStrings you can use the CString::GetLength() function:[tt]

CString str = "hello";
int length = str.GetLength();
tellis.gif

programmer (prog'ram'er), n A hot-headed, anorak wearing, pimple-faced computer geek.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top