I'm using atom to write code in C++. When I compile my code in the terminal using g++ -Wall -std=c++14, it prints and compiles properly in the terminal. Any revisions to my code after the first print however, do not transfer over to my terminal, and when I run the same code, the original always prints. I'm saving my source code in atom everytime I make a revision. If I save the exe file in atom it becomes a binary and does not print anymore. Does anyone know how I can get my source code to update in my terminal when I save it? Any help would be great.
Asked
Active
Viewed 295 times
0
Andy Dalton
- 13,654
- 1
- 25
- 45
-
Are you recompiling with `g++` after you save you changes to the source? – Andy Dalton Jul 02 '20 at 21:38
-
No im just saving then re-running with ./exename. I know I could recompile every time, but in the Udemy course im taking, the instructor was able to just re print after saving without recompiling. If that's the correct way to do it i'll do that, but since our method looked different I assume there is a way not to have to re-compile? If not lmk please. – C. V-Ayers Jul 02 '20 at 21:48
-
2You definitely need to recompile. There may be an option to recompile on save. – icarus Jul 02 '20 at 22:11
1 Answers
4
In C++ (like in any other compiled languages) you always have to recompile after modifying your source code. I'm suspecting your teacher is using a development environment which compiles and executes on a single button press. For a tiny example that might be so fast you don't even notice. With a "dumb" editor follow the following steps:
- Modify source code, save.
- Compile in a terminal by running
g++ -Wall -std=c++14 - Execute
./a.out
Martin Konrad
- 2,090
- 2
- 16
- 32