Why is my first C++ program not showing output?

0
10
Asked By CuriousCoder99 On

Hey everyone, I'm new to programming and I'm having some trouble with my first C++ program. I ran the command `g++ -o code day2.cpp` in the terminal, and it showed no errors, but I don't see any output in the output area. When I tried running it with `./day2.exe`, it executed and printed on the terminal. Can someone explain what's going on? I'm really confused about this!

1 Answer

Answered By HelpfulHarry42 On

It sounds like you have a common misunderstanding about the compilation and execution process. When you use `g++ -o code day2.cpp`, you're only compiling your program. This step converts your source code into an executable file, and you're not supposed to see any output at this stage if there are no errors. It's only when you run the program with `./day2.exe` that you'll actually see the output you expect, as that's when your code is executed.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.