
December 6th, 2012, 02:55 AM
|
|
Registered User
|
|
Join Date: Dec 2012
Posts: 2
Time spent in forums: 32 m 45 sec
Reputation Power: 0
|
|
I am having trouble removing the leading spaces
what i have to do is remove the white spaces and change it to last first. (ex. ^^^^Charlie^^^Brown turns in to Brown, Charlie.)^ is a space
The problem i am having is that some of the last names are not being displayed.
What is going in
^^^^^^^Eric^^^^Kim^^
^^David^^^^^^Beazley^^^^
^^^Brad Howes^
^Scott^^^^^Stanton
Tim Kientzle^^
^^^^^^Ray^^Lischner^^^^^^^
Douglas Troy
Whats coming out
Kim, Eric.
Beazley, David.
Howes, Brad.
, Scott. // No last name
Kientzle, Tim.
Lischner, Ray.
, Douglas. //no last name
ItemType parseInputItemType(ItemType line)
{
ItemType first, last, temp;
bool next= false;
for(int x = 0; x < line.length() -1; x++)
{
if(!isspace(line.at(x)))
{
temp = temp + line.at(x);
if(line.at(x+1) == ' ' and next == false )
{
first = temp;
temp = "";
next =true;
}
if(line.at(x+1) == ' ' and next == true )
{
last = temp;
temp = "";
}
}
}
return (last +", " +first +'.');
}
|