简体   繁体   中英

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:

#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. 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)

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:

#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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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