This lesson may or may not be a bit longer. I'm not only going to talk about functions because in this lessons I want to introduce some actual real life coding.
Hopefully you downloaded C++ Express like I mentioned. If you haven't I recommend doing so now (unless you already have some form of Visual C++).
To begin, open Visual C++ Express edition. Click "File", then hover over "New" and select "Project..." A new dialog box will open up which allows you to select what type of project you want to create, the name of the project, and where you want it to be created. Visual Studio automatically creates a directory for keeping all of your projects so I recommend leaving the project location at default. Also, leave the "Create directory for solution" checkbox checked which it should be by default. If it's not checked then check it. Feel free to name the project anything you like, I recommend "CLessons" or something similar.
On the upper half there's a list of options on the left. Click "Win32" and this will open up more options on the right side. Highlight "Win32 Console Application" and then, after making sure you named the project, click "Ok"
After this a ewn dialog box will open. Click "Next" to go to the next page of the dialog. Make sure "Console application" is chosen for "Application type" and check the "Empty project" option under "Additional options"
Click finish and your new project will be created. At this point you should see a list of items on the left in a window called "Solution explorer". You should see the name of your project (ie "CLessons" or whatever you named it) and underneath this three folders named "Header files", "Resource files", and "Source files".
Right click "Source files", hover over "Add" and click "New item..." A new dialog box will open similar to the "New project" dialog. This will be your C++ source file which will contain the code of your project. Name the file whatever you want, but I recommend something like "Main". On the upper half click "Code" on the left hand side and then "C++ File(.cpp)" on the right side. After doing this and naming it click "Add"
Now you have a blank sheet to fill with code. Type the following code in:
int main()
{
int a = 0;
int b;
return 0;
}
After this you can click the run button to build and execute your program. The run button looks like a little green play button on the top toolbar in visual studio. It will ask if you want to build your program so just click "Yes" to have it build your program and run it. This program will do nothing but initialize 2 integers so you'll only see a command prompt window open then immediately close.
Well, I know I said this would be a lesson about functions but I guess it turned out not to be. I'm going to leave this here and explain what's going on next lesson. Ok, on second thought I'm going to stop saying what I'm going to do next lesson because I usually end up changing. See you next lesson!
Monday, February 4
as provided to you by Bob @~~~ 6:23 PM
Subscribe to:
Post Comments (Atom)
0 \comm\e.nts:
Post a Comment