Read File line by line using C++
<p>I am trying to read a file line by line using the code below : </p>

<pre><code>void main()
{
    cout &lt;&lt; "b";
    getGrades("C:\Users\TOUCHMATE\Documents\VS projects\GradeSystem\input.txt");
}

void getGrades(string file){

    string buf;
    string line;
    ifstream in(file);

    if (in.fail())
    {
        cout &lt;&lt; "Input file error !!!\n";
        return;
    }

    while(getline(in, line))
    {
        cout &lt;&lt; "read : " &lt;&lt; buf &lt;&lt; "\n";
    }

}
</code></pre>

<p>For some reason it keeps returning "input file error!!!". I have tried to full path and relative path (by just using the name of the file as its located in the same folder as the project). what am I doing wrong?</p>
