Lab 00 - C++ Coding Setup - Windows Edition
Overview
In this course, you'll need to solve some problems using the C++ language. For this assignment, you'll make sure your C++ development environment is set up correctly.
The following instructions are for the Linux operating system.
1. Install the c++ compiler
Use whatever package manager your linux system uses to install the GNU c++ compiler.
For example, on Ubuntu / Kubuntu / Mint distributions, you would use:
sudo apt-get install build-essential
2. Install a text editor
Install a programmer's text editor. There are dozens of these available, most for free. Some options include: emacs
, spacemacs
, vim
, Atom
, or Sublime Text
.
3. Write some code
Create a new file called main.cpp
. Write the following code in that file:
#include <iostream>
int main() {
std::cout << "Hello world!\n";
return 0;
}
The main
function is the entry point to C++ programs. std::cout
is the console output stream object. The above code uses the stream operators (<<
) to stream the text "hello world!", followed by a new line, to the console output, causing the text to appear on the screen.
Save the file and exit the text editor.
4. Compile and run the code
From the command line, navigate to the directory containing your .cpp
file and compile it with g++:
g++ main.cpp
This produces an executable file called a.out
. Execute that file:
a.out
You should see the text "Hello world!" displayed on the screen.
5. Submission
To finish up, modify the code so that instead of "Hello World", it says "Hello, YOUR NAME". So if my name were Lee, it should say "Hello Lee".
Recompile the progam to produce a new a.out
file.
Run the a.out
file to make sure it works, then submit the main.cpp
file to mySVU.
If mySVU gives you an error about the file type, put the main.cpp
file in a zip file and upload the zip file.