Whenever I try to update my code in C++(VSCode) with the g++ thing, it doesn’t update what I put even after deleting the old .exe file

enter image description heremy code looks like ^^^ (comments because i make a file for notes on a new programming language im learning to look back at to help me)

I will put g++ filename.cpp and then ./a.exe after making a change and it doesn’t change the output in the terminal. So for example if I put a 🙂 at the end of the last string, it wouldn’t update what it puts in the terminal even after doing g++ filename.cpp. I’ve tried deleting the older a.exe file before doing g++ but it doesn’t fix the problem.

Answer

Please make sure you are actually using the GCC Compiler and that you are not getting errors at the moment of compile your code. You can use this to check the compiler: g++ --version; if you don’t have the compiler installed, it will give you an error.

Also, at the moment of compile your code, you should use the g++ installed on your computer with the .cpp file that you want to compile and create the .exe file.

Example:

  1. Here we have Basic00.cpp having a simple “hello world”:
    Image with the .cpp file

  2. Then, we run g++ .Basic00.cpp

  3. It will create the a.exe file:
    Image with the a.exe file

  4. Now you just need to run .a.exe:
    Image with the output

  5. And, if you want to add “:)” at the end of the string, you just need to add it, compile the code again (step 2) and run the exe file (step 4):
    Here you can see it

I recommend that you read this about how to use VS Code with G++ to compile and run your code without having issues. Very important: Remember that you need to compile your code every time that you make a change.

Edit with the new Image: I checked your image and the tab is showing a white circle, it means that you are not saving the changes, press Ctrl+S (to save) or configure Auto Save on File -> Auto Save, after saving compile your code again and run the .exe file.