Complete Beginner - Help Writing C++ Code
-
Hi everyone,
I’m an absolute beginning and would appreciate any guidance you can give me! I have the most basic of questions for you.
I just started a programming class with no programming experience. I would like to use Notepad++ to write my programs for class. I have to submit them as a .cpp file.
Is there a place I can find a walkthrough for a beginner? I can figure out how to start a new file and input my code, but I don’t know what to do next. How do I run the program to make sure it works before I submit it to my professor? When I select “run” in the menu, it makes me choose a file, and then I am confused. I want to run the code I just typed in, not pick a file.
Thanks in advance!
-
Generally you will use NPP to edit your programs, but not to “run” them. It is possible to do that, but it is a bit of an advanced feature.
First, you will need to write your program using NPP and save it. This version of the program is referred to as your program’s source code.
Next you have to compile the source code with some C++ compiler, perhaps a particular one supplied by your instructor. The compiler creates an executable version of your program which on Windows will no doubt be named <something>.exe.
The .exe is the file that you run and see if it does what you intended when you wrote the source code.
-
Thank you, Jim! :-) This makes sense. So do I write my code in NPP, then copy and paste it into a compiler?
-
Your first part is correct: You write your code in Notepad++. Your second part is wrong–it should be: You run the compiler and tell it where to find the file you created and saved in N++.
-
Thanks, Scott! That makes more sense than copying and pasting.
I went to my professor’s office last night, and he walked me through using the compiler. I think I’m all set now. It has been a steep learning curve.
This does give me a lot more appreciation for programmers and the complexity of what they’re doing when they make apps and games for us.
-
If you keep going, you will REALLY get an appreciation for that!