This is the snippet of code that I'm puzzled about.
I'm checking for how long an incoming string is.
I've appended *
in order to have a sentinel value to stop the while loop.
Yet, I'm consistently getting a length value that is inclusive of the *
and I don't understand why, since the while loop with the nested if ought to stop prior to the *
.
Can someone point out what I'm doing wrong and why I'm having this issue?
void conversion(string romanIn)
{
length=0;
romanIn.append("*");
while(item!="*")
{
if(item != "*")
{
item = romanIn[length];
length++;
}
cout<<item;
}