C++ introduction: self study
<p>I created the program to read from text file and remove special characters. I can't seem to code better the if statement. Please help. I searched online for the right code statements but they have all advanced code statements. The book I am learning from has the last(14th) chapter with strings and file open and closing code. I tried creating an array of special chars, but did not work. Please help me!</p>

<pre><code>     int main()
     {


 string paragraph = "";
 string curChar = "";
 string fileName = "";
 int subscript=0;
 int numWords=0;


 ifstream inFile; //declaring the file variables in the implement
 ofstream outFile;


       cout &lt;&lt; "Please enter the input file name(C:\owner\Desktop\para.txt): " &lt;&lt; endl;

       cin &gt;&gt; fileName;


 inFile.open(fileName, ios::in); //opening the user entered file

 //if statement for not finding the file
 if(inFile.fail())
 {
  cout&lt;&lt;"error opening the file.";
 }
 else
 {
 getline(inFile,paragraph);
 cout&lt;&lt;paragraph&lt;&lt;endl&lt;&lt;endl;
 }


 numWords=paragraph.length();

 while (subscript &lt; numWords)
 {

  curChar = paragraph.substr(subscript, 1);


      if(curChar==","||curChar=="."||curChar==")"
   ||curChar=="("||curChar==";"||curChar==":"||curChar=="-"
   ||curChar=="\""||curChar=="&amp;"||curChar=="?"||
      curChar=="%"||curChar=="$"||curChar=="!"||curChar=="                ["||curChar=="]"||
   curChar=="{"||curChar=="}"||curChar=="_"||curChar=="  &lt;"||curChar=="&gt;"
     ||curChar=="/"||curChar=="#"||curChar=="*"||curChar=="_"||curChar=="+"
   ||curChar=="=")


  {
   paragraph.erase(subscript, 1);
   numWords-=1;
  }
  else 
   subscript+=1;

 }

 cout&lt;&lt;paragraph&lt;&lt;endl;
 inFile.close();
</code></pre>
