简体   繁体   English

Code :: Blocks-Linux-即使“ main.cpp”文件中没有该文件,也会打印“ Hello World”

[英]Code::Blocks - Linux - prints “Hello World” even though it isn't in the “main.cpp” file

I have recently started a few projects to help me learn C++, I am creating a program that allows the user to enter a grade score /100, the code is as follows: 我最近启动了一些项目来帮助我学习C ++,我正在创建一个程序,该程序允许用户输入分数/ 100,代码如下:

#include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main (gradeScore)
{
    int gradeScore
    cout << "Enter your grade score out of 100"
    cin >> gradeScore

    if (gradeScore == 100)
    {
        cout << "Well done! You have achieved a perfect score!.."
    {
}

I tried compiling it just to make sure that it was working so far, however, it opens up the terminal and prints 我尝试编译它只是为了确保它到目前为止可以正常工作,但是,它打开了终端并打印

Hello World! 

Process returned 0 (0x0)    execution time : 0.013 s
Press ENTER to continue.

I'm not sure what to do about it, there's nowhere in the project that contains the string "Hello World" anywhere. 我不确定该怎么做,项目中的任何地方都没有包含字符串“ Hello World”的地方。 Could someone please help me? 有人可以帮我吗? I just want to be able to carry on my learning without and hinderance like this. 我只希望能够这样无障碍地进行我的学习。

I'm using Code::Blocks 13.12 rev 9501 (2013-12-25 18:25:45) gcc 4.8.2 Linux/unicode - 32 bit (not sure if this is helpful) 我正在使用Code :: Blocks 13.12 rev 9501(2013-12-25 18:25:45)gcc 4.8.2 Linux / unicode-32位(不确定是否有帮助)

Thanks guys. 多谢你们。

I'd like to thank you for your advice and help, I'm sure it's frustrating seeing questions like this all the time off us noobs. 我要感谢您的建议和帮助,我敢肯定,无聊的时候总是看到这样的问题。

I have solved the problem and it turns out the solution was stupidly easy: I deleted the project, made a new one, opened the main.cpp file and found this cheeky little bugger sitting on the file: 我已经解决了问题,结果发现解决方案非常简单:我删除了该项目,制作了一个新项目,打开main.cpp文件,发现坐在文件上的这个厚脸皮的小虫子:

#include <iostream>
using namespace std; 

int main()
{
    cout << "Hello World!" <<endl;
}

I deleted it and corrected my original program to this: 我删除了它,并将原始程序更正为:

#include <cstdio>
#include <cstdlib>
#include <iostream>
using namespace std;

int main()
{
    int gradeScore;
    cout << "Input test score out of 100:";
    cin >> gradeScore;

    if (gradeScore == 100)
    {
        cout << "Congratulations! You achieved a perfect score" << endl; 
    {
}

Again, thank you for your patience guys! 再次感谢您的耐心等待! I promise I'm trying hahaha! 我保证我正在尝试哈哈哈!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM