title: C++ Error: Undefined Symbol
body: <p>The point of my code is to be able to enter a file with blank-n somewhere within the text. It is suppose to change blank-N to a user prompted code such as (blank-N) =noun and asks the user to enter a noun but for some reason I am getting that error
  So here is my code:</p>
  
  <pre><code>    //Author:
  //
  //
  //
  //
  //
  
  #include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  using std::string;
  using namespace std;
  
  string getWord(ifstream &amp;Infile, char &amp;ch);
  void getFilename(ifstream &amp;Infile);
  void getOutfile(ofstream &amp;Outfile);
  void putWord(ostream &amp;Outfile,string word, char space);
  string replacement(string word,std::string);
  void printprompt(int i);
  int main()
  {
    ifstream filename;
    ofstream outfile;
    string file;
    string word;
    char ch;
    getFilename(filename);
    getOutfile(outfile);
    while(!filename.eof())
      {
        file =getWord(filename,ch);
  
        putWord(outfile,file,ch);
      }
    filename.close();
    outfile.close();
    return 0;
  }
  
  string getWord(ifstream &amp;Infile, char &amp;ch)
  {
    string wrd = "";
  
    Infile.get(ch);
    while(ch !=' '&amp;&amp; ch != '\n' &amp;&amp; !Infile.eof())
      {
        wrd.append(1,ch);
        Infile.get(ch);
      }
    return wrd;
  }
  
  void getFilename(ifstream &amp;Infile)
  {
    string filename;
    cout&lt;&lt;"File for input: ";
    cin &gt;&gt;filename;
  
    Infile.open(filename.c_str());
    if (Infile.fail())
      {
        cout &lt;&lt; "Cannot open"&lt;&lt;filename&lt;&lt;endl;
        exit(0);
      }
  }
  
  void getOutfile(ofstream &amp;Outfile)
  {
    string filename;
    cout&lt;&lt;"file for output: ";
    cin&gt;&gt;filename;
    Outfile.open(filename.c_str());
    if(Outfile.fail())
      {
        cout&lt;&lt; "Cannot open"&lt;&lt;Outfile&lt;&lt;endl;
        exit(0);
      }
  }
  
  void putWord(ofstream &amp;Outfile,string word, char c)
  {
  
    Outfile &lt;&lt; word;
    if (c =='\n')
      Outfile&lt;&lt;endl;
    else
      Outfile&lt;&lt;" ";
  }
  string replacement(string word)
  {
    string key[5]={"blank-N", "blank-A","blank-V","blank-P","blank-D"};
    for(int i =0; i&lt;5;i++)
      {
        if(word.compare(key[i]))
          {
            printprompt(i);
            cin&gt;&gt;word;
          }
  
        return word;
      }
  }
  void printprompt(int i)
  {
    switch(i)
      {
      case 0:
        cout&lt;&lt;"Please enter a noun";
        break;
      case 1:
        cout&lt;&lt;"Please enter an adjective";
        break;
      case 2:
        cout&lt;&lt;"Please enter a verb";
        break;
      case 3:
        cout&lt;&lt;"Please enter a place";
        break;
    default:;
  
      }
  }
  </code></pre>
  
  <p>and I seem to be getting this error:  </p>
  
  <pre><code>    Undefined                       first referenced
   symbol                             in file
  putWord(std::basic_ostream&lt;char, std::char_traits&lt;char&gt; &gt;&amp;, std::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;, char)/var/tmp//ccdj0m4f.o
  ld: fatal: Symbol referencing errors. No output written to a.out
  collect2: ld returned 1 exit status
  </code></pre>
  
  <p>I do not know how to prevent this error from happening.</p>