Comparing a string with a character in C++
<p>Hey Guys, I'm trying to write a program that calculates the GPA of a student. For some reason the compiler is giving me an error when comparing two strings, but I cant seem to find the reasons for it. Below you will find the piece of code that is giving me error. I would really appreciate if someone could help me figure it out.</p>

<p>ERROR: cannot convert ‘std::string’ to ‘const char*’ for argument ‘1’ to ‘int strncmp(const char*, const char*, size_t)’</p>

<pre><code>double StudentInfo::getGPA() {
double temp = 0;
for(int i = 0; i &lt; totalCourses; i++) { 
    if(strncmp(Courses[i].getGrade(), "A") == 0) //Gets string "grade", and compares it to "A".
        temp = temp + 4;
    if(strncmp(Courses[i].getGrade(),"A-", 2) == 0)
        temp = temp + 3.7;
    if(strncmp(Courses[i].getGrade(), "B+", 2) == 0)
        temp = temp + 3.3;
    if(strncmp(Courses[i].getGrade(), "B") == 0)
        temp = temp + 3;
    if(strncmp(Courses[i].getGrade(), "B-", 2) == 0)
        temp = temp + 2.7;
    if(strncmp(Courses[i].getGrade(), "C+", 2) == 0)
        temp = temp + 2.3;
    if(strncmp(Courses[i].getGrade(), "C") == 0)
        temp = temp + 2;
    if(strncmp(Courses[i].getGrade(), "C-") == 0)
        temp = temp + 1.7;
    if(strncmp(Courses[i].getGrade(), "D+") == 0)
        temp = temp + 1.3;
    if(strncmp(Courses[i].getGrade(), "D") == 0)
        temp = temp + 1;
    else
        temp = temp + 0;
}
GPA = temp/totalCourses;
return GPA;}
</code></pre>
