September 12th, 2003, 09:58 AM
How to get last 3 characters from a string?
:D Hi all, I'm new to C++ and this forum.
ok,here is the problem. the function is supposed to creat a customer ID made up of:-
First little of name,second name, and surname
First 3 characters of streat
Last 3 characters of city
There is no error with complie, but the program doesn't display the customer ID.
here's my code:
Last edited by goodwilllV; September 12th, 2003 at 10:08 AM.
September 12th, 2003, 12:00 PM
Try size - 3 instead of size - 2:
printCustomerID = "Customer ID: " + firstName.substr(0,1) + secName.substr(0,1)
+ surName.substr(0,1) + "-" + printPerson.substr(0,3) + city.substr(size-3,3);
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
September 12th, 2003, 07:49 PM
thank u for ur reply!
however, the problem just like it was by size-3.