2013-09-25, 08:18 PM
SaptaZapta Wrote:Code:SENTENCE Empty = {"", "", "", "", "", "", "", ""};
Line = Empty;
Okay good, I was on the right track then!
And as for the if explanation, that makes all kinds of sense now. And as for the GetWord function, all I did was remove the error functions because they were (ironically) giving me errors, I don't think the program recognized them at all. I'm going to assume that there won't be two of the same indicator entered.
Code:
void GetWord(istream & inF, int & linepos, int & wordpos, string & word)
{
char ch; //Variable to check for indicators.
int num; //Position numbers before position check.
linepos = -1;
wordpos = -1; //These have not been given values yet and 0 is part of the sentinel: -1 is thus used.
//Read two numbers in unknown order and with possible whitespace between them.
do
{
if (ch == '+' || ch == '-') //Checks for position indicator before number.
{
inF >> num; //Number comes after indicator, number is being read next.
if (ch == '+')
{
linepos = num; //Gets line position if indicator is +.
}
else
{
wordpos = num; //Gets word position if indicator is -.
}
}
else if (ch == ':') //If no position indicator, checks for the start of the sentinel character, which is :.
{
// read the next 3 characters and if they are :0:0: then exit, otherwise exit with format error message - not coded yet
}
} while (linepos < 0 || wordpos < 0);
inF >> word; //Read word after positions.
return;
}
