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

Remove

Status
Not open for further replies.

mayu03

Programmer
Oct 3, 2003
91
US
I have the following string '00001762'. Sometimes it can be '00000562'. How do I remove all unwanted 0 before the actual number?
 
all chars after first character which not exuals to 0 move to the begin of the string, including the ending '\0'

Ion Filipski
1c.bmp
 
a simple way:

CString strMainNumber = "00001762"; // or "00000562"
long number = atol((LPCTSTR)strMainNumber); // or _wtol
CString strTrimNumber;
strTrimNumber.Format(_T("%ld"), number);
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top