Program breaks before it is supposed to in C++

Not sure how I was supposed to formulate title!

I’m trying to write a program that asks the user for the name of a student. Then it stores that name in a struct and asks for a course name and the grade for that course. It does this until the course name is stop. Then it asks for another student until the name given is stop.

Here is my code:

#include <iostream>

using namespace std;

struct student{

    string name;
    string course;
    int grade;


int main() {

    while ( != "stop"){
        cout << "Please type the name of a student: " << endl;

        if ("stop")){
            if ("stop")){
            else {
                cout << "Please type a course name: " << endl;
                getline(cin, student_t.course);
                cout << "Please type the grade: " << endl;
                cin >> student_t.grade;

    cout << << " - " << student_t.course << " - " << student_t.grade << endl;

    return 0;

The problem is, it exits no matter what name I type.

Any ideas?

>Solution :

It should be:

if ("stop") == 0){

Leave a Reply