title: Searching the last character of a string for punctuation
body: <p>I'm currently working on making a little word processor and I've come across an issue. I'm trying to make the program so that when you press enter, the program will put a full stop on your input and then a space (I'll sort out paragraphs later). The issue is that I can't get the program to search the last character for punctuation and then branch on the result. The compiler gives me the following error: <strong>ISO C++ forbids comparison between pointer and integer.</strong> The code I currently have is: </p>
  
  <pre><code>#include &lt;fstream&gt;
  #include &lt;string&gt; 
  #include &lt;iostream&gt;
  #include &lt;cstring&gt;
  #include &lt;limits&gt;
  using namespace std ;
  
  int main() 
  {
  int i = 0;
  string text ;
  string text2 ;
  string title ;
  string usertitle ;
  string filelocation = "C:/Users/" ;
  string user ;
  string punctuation = ". : ! ? "
  
  cout &lt;&lt; "Input a title for your file: " ;
  getline(cin , title) ;
  title.insert(title.length() , ".txt" ) ;
  cout &lt;&lt; "Your title is: " &lt;&lt; title &lt;&lt; endl ;
  cout &lt;&lt; endl &lt;&lt; "Input the username associated with your computer: " ;
  getline(cin , user) ;
  filelocation.append( user ) ;
  filelocation.append("/Documents/") ;
  filelocation.append(title) ;
  cout &lt;&lt; "Your chosen file name and location is: " &lt;&lt; filelocation &lt;&lt; endl ;
  for ( i = 1 ; i &gt; 0 ; i++ )
  {
      if (text == "") 
      {
          cout &lt;&lt; "There are a few instructions that you need to follow in order to use this system effectively: " &lt;&lt; endl ;
          cout &lt;&lt; "The first being that if you want to use it, you actually have to use a directory that exists. " &lt;&lt; endl ;
          cout &lt;&lt; "The second being that when you want to exit the program you press enter with nothing typed" &lt;&lt; endl ;
          cout &lt;&lt; "The third being NOT TO USE FULL STOPS, THE PROGRAM WILL PUT THEM IN FOR YOU" &lt;&lt; endl ;
          cout &lt;&lt; "Please begin writing: " &lt;&lt; endl ;
          getline(cin,text) ;
      } 
      if (text!="")
      {
          text2.append(text) ; //&lt;===HERE IS WHERE I AM HAVING TROUBLE
          if ((text.at(text.size() -1 ) != "!" ) &amp;&amp; (text.at(text.size() -1 ) != "?") &amp;&amp; (text.at(text.size() -1 ) != ":" )) 
          {
              text2.append(". ") ;
              getline(cin, text) ;
          }
          else
          {
              getline(cin, text) ;
          }
          if (text == "") 
          {
              cout &lt;&lt; "End of session" &lt;&lt; endl ; break ;
          }
      }
  }
  
  ofstream writer( filelocation.c_str() ) ;
  if(! writer) 
  {
      cout &lt;&lt; "Error opening file for output: " &lt;&lt; strerror(errno) &lt;&lt; endl ;
      return -1 ;
  }
  else 
  {
      writer &lt;&lt; text2 &lt;&lt; endl ;
      writer.close() ;
  }
  
  return 0 ;
  }
  </code></pre>
  
  <p>Thanks for your help in advance!</p>