什么是C ++中的EOF键 [英] what is EOF key in C++

查看:209
本文介绍了什么是C ++中的EOF键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Windows 7旗舰版。我是C ++的新手。以下是我对switch语句的练习。

I am using Windows 7 Ultimate. I am new to C++. Following is my exercise for switch statement.

void GradeBook::inputGrades()
{
    int grade;

    cout << "Enter Grade: " << endl;

    while((grade=cin.get()) != EOF)
    {
       switch(grade)
        {
            case 'A':
            case 'a':
                aCount++;
                break;

            case 'B':
            case 'b':
                bCount++;
                break;

            case 'C':
            case'c':
                cCount++;
                break;

            case 'd':
            case 'D':
                dCount++;
                break;

            case 'F':
            case 'f':
                fCount++;
                break;

           case '\n':
           case ' ':
           case '\t':
               break;

            default:
                cout << "Incorrect data. Re Enter" << endl;
                break;
        }

    }
}

我跑这个内部netbeans,我按下所有组合ctrl + c,ctrl + z,ctrl + d但它没有结束!!这是为什么?我做错了什么吗?请帮助!!

I run this inside netbeans, and I pressed all the combinations ctrl+c , ctrl+z, ctrl+d but it is not ending!! Why is that? Have I done something wrong? Please help!!

推荐答案

EOF字符是Ctrl + Z,后跟Windows平台上的换行符。

An EOF character is Ctrl+Z followed by a newline character on Windows platforms.

据推测,Netbeans中的控制台也是如此。

Presumably that will be the same for the console within Netbeans.

这篇关于什么是C ++中的EOF键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆