I got that, but I'm still not getting the desired output. Here is what
I have so far:
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
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();
for(int j = 0; j < length + 1; j++)
tempword[j] = tempword[j];
words[i] = tempword;
}
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
words[i] = tempword;
}
else
{
cout << "no position matches" << endl;
words[i] = tempword;
}
}
}
Jon Bell wrote:
In article <Mnywb.6324$ML6.1502@fed1read01>,
Rick <rf*****@NOSPAMcox.net> wrote:
How do I check if tempword[0] equals a '
I get an error when I do tempword[0] == '''
Try tempword[0] == '\''
The backslash tells the compiler that you want it to use the second ' as a
literal character, not as a quote mark to delimit another character (its
normal function in a C++ statement).