Rick wrote:
>
> I got that, but I'm still not getting the desired output. Here is what
> I have so far:
Devloping debug techniques is something you need to learn.
Just in case you don't have a debugger (which would simplify
things) why not insert some output statements at strategic
positions to enable yourself to watch what the program
is doing and why.
eg.
>
> void convertarray(string words[], int count)
> {
> int lastpos;
> string tempword;
> int length;
> bool yes;
>
> for(int i = 0; i < count; i++)
> {
> tempword = words[i]; //file?
> lastpos = tempword.length() - 1; //4
cout << "word is " << tempword << endl;
cout << "lastpos: " << lastpos << endl;
> if(tempword[0] == '!' || tempword[0] == '(' || ')' || tempword[0]
> == '"' || tempword[0] == '?' ||
> tempword[0] == '.' || tempword[0] == ':' || tempword[0] == ';' ||
> tempword[0] == ',' ||
> tempword[0] == '\'')
> {
> cout << "first position matches" << endl;
> length = tempword.length();
cout << "copying first" << length << " characters" << endl;
> for(int j = 0; j < length + 1; j++)
{
cout << "copy " << tempword[j] << " (" << j << ") to position" << j << endl;
> tempword[j] = tempword[j];
}
> words[i] = tempword;
cout << "new word is " << tempword << endl;
// note: the above loop does .... nothing
// that means, of course it does something. It copies
// the j-th character to the j-th character. In the
// end tempword hasn't changed
> }
> if(tempword[lastpos] == '!' || tempword[lastpos] == '(' ||
> tempword[lastpos] == '"' ||
> tempword[lastpos] == '?' || tempword[lastpos] == '.' ||
> tempword[lastpos] == ';' ||
> tempword[lastpos] == ',' || tempword[lastpos] == '\'')
> {
> cout << "last position matches" << endl;
> length = tempword.length(); //4
> for(int k = 0; k < length; k++)
> tempword[k] = tempword[k];//file
// Here again.
// What's this loop got to do?
// it copies the k-th character from tempword to the k-th character
// in tempword. No changes in tempword result from this.
//
> words[i] = tempword;
> }
> else
> {
> cout << "no position matches" << endl;
> words[i] = tempword;
> }
> }
> }
--
Karl Heinz Buchegger