FAQ: Compile & Execute - Review

This community-built FAQ covers the “Review” exercise from the lesson “Compile & Execute”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn C++

FAQs on the exercise Review

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

How do you save the hello.cpp on my computer to execute the code on my computer?

3 Likes

why we should add comment it it’s not going to get compiled ?

If I change the text in the std::cout, compile the code like g++ hello.cpp -o name, and then execute it like ./name, it still says “Hello World!”

Why is this?

I might be mistaking your issue but chances are the actual file hasn’t been saved and updated. Try using the run (or save) button below the text editor section to make sure it has saved an updated version of your file before compilation.

1 Like

Ooh yeah I think that’s it thanks

2 Likes

I’ve installed MSYS2 according to these directions here as per the Codecademy lesson: https://www.msys2.org/ and setup the environment variables. Now when I compile in CMD there’s no issue, but when I try to execute I get the error: “’.’ is not recognized as an internal or external command,
operable program or batch file.” Why is g++ recognized and ./ is not? I checked the folder C:\msys64\mingw64\bin where I saved the file and I have g++ in the bin folder but not ./ Could that be part of the issue?

1 Like

As it stated, the terminal doesn’t recognize “,” as a command. If you want to run the executable, you’ll have to type out the whole directory (e.g. C:\Projects\hello).

just to clarify what we are doing

@dv2s6 I had the same question you’ll have to install msys2 and add a variable to path under user variables to point mingw bin folder here you can watch it detailed Get Started with C++ and Mingw-w64 in Visual Studio Code

@method3337998875 in windows you dont have to use ./ to run the program simply type the name
eg. g++ hello.cpp -o hello you type hello in the command line to run the program

Is MSYS2 for windows? I don’t understand if it is for linux users trying to build windows apps
and what is the codecademy lesson? I want to compile c++ programs

edit: already compile a c++ program

When I resume the course always send me to this lesson fix it I already have done the logical operators I hope someone of the staff will read this if not where I can report this?