ifstream ofstream on mac
<p>I'm trying to read in a random file (on mac-xcode) and determine the instances of the letter k in the document. Then print the number as an outout file. My problem is that the outfile isn't being written and the nums_k is coming back as 0. I'm not sure if the ifstream is working incorrectly or the ofstream need a different filename established. Here's my source code. </p>

<pre><code>#include &lt;iostream&gt; 
#include &lt;fstream&gt; 
#include &lt;string&gt;  
using namespace std;  

int main() { 

    ifstream infile("Users/bryanmichaelnorris/documents/extra credit    assignment.docx"); 

    string line; 
    int numks = 0;  

    while (getline(infile,line)) {     
         int x = 0;         
         for (std::string::iterator it=line.begin(); it!=line.end(); ++it) {            
             if (line[x] == 'k') {                 
                  numks++;            
             }            
             x++;         
         }     
    }         

    infile.close();     
    ofstream outfile("number of k's.docx");   
    outfile &lt;&lt; "There are " &lt;&lt; numks &lt;&lt; " K's in the file." &lt;&lt; endl;
    outfile.close();        
    return 0;
}
</code></pre>