Sinclair Sprockets
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Into to Programming

3 posters

Go down

Into to Programming Empty Into to Programming

Post  William Surmak Wed Oct 08, 2014 7:11 pm

Hey guys, ill be making some tutorials to go along with what i'm teaching during the meetings. These will help me explain things in more detail and hopefully allow you to understand things a bit better. Anyone can program, so everyone is welcome to follow along.

Step 1: Getting a compiler

You'll need a compiler. I personally use Microsoft visual studio express 2013 (not professional, unless you want to pay) 
http://www.visualstudio.com/en-us/products/visual-studio-express-vs.aspx
Ensure you scroll down a bit and get the one for desktop.

Alternative:
http://www.bloodshed.net/dev/devcpp.html
It's older and uglier but it also gets the job done.

Ill be using visual studio in my tutorials.

Step2: Creating a project

Launch visual studio and navigate as follows file -> new project ->win32 console application -> ok -> next -> check empty project -> finish
We now have an empty project. The next step is to add the file containing our code. Left click source files in the solution explorer -> add -> new item -> c++ file -> add
You should now have a blank white screen, ready for you to type something. Copy and paste this code and click the green arrow at the top called local windows debugger. You should have a black window pop up saying press any key to continue. If not you did something wrong

Code:
#include <iostream>

using namespace std;

int main()
{
   system("pause");
}

If it worked then good job, this will serve as the base code for everything you will write in c++. I've got a physics test to study right now, but more tutorials will follow soon.

If you want to work ahead or are generally confused with anything in the tutorials to come, then I highly recommend watching this guys YouTube videos.
https://www.youtube.com/watch?v=tvC1WCdV1XU&list=PLAE85DE8440AA6B83
They are clear and easy to follow. Note he is using the code blocks compiler, this doesn't matter, the code he types in will work the same if typed in your visual studio source file.
William Surmak
William Surmak

Posts : 104
Join date : 2011-10-12

Back to top Go down

Into to Programming Empty thanks Wil

Post  chefjohn Mon Oct 13, 2014 10:54 pm

I will try and follow along with your lessons this year, thanks
chefjohn
chefjohn
Admin

Posts : 158
Join date : 2012-06-19

Back to top Go down

Into to Programming Empty Explaining the base code / hello world

Post  William Surmak Wed Oct 15, 2014 11:21 pm

It's time to look into our base code in more detail...

You may be looking at our base code and be thinking what in the world is #include <iostream> Well, it is whats known as a header file. These header files contain important tools in our coding life. iostream (input-output stream) is used for yup.. you guessed it, input and output. Other examples of header files are <math.h> (used for advanced math such as our trig functions) and <time.h> (used for timing things). Also notice they have these < > surrounding their name, this is the proper way to include them.

Next up is using namespace std; I won't go into much detail but this just says we are working in the standard workspace. 


Then int main(). This signifies the start of our program. The compiler will search for this line and run whatever is in the curly brackets following it. Inside these brackets we have the command system("pause");. This is a line which will pause the black screen that pops up on your computer. If you were to take away this line, the black window would just flash for a second and then exit.

So what's up with the semicolons? Well... think of a semicolon as a period, it signifies the end of a line. However, it does not go after every line such as our include statement. You'll pick up on where to put semicolons and where not to, but for now just assume that everything within our main section needs a semicolon and everything outside those curly brackets do not (except using namespace std!).

Now in the main loop we will add a command above the system("pause"); This command is cout (c - out). It is written as so
cout << "whatever you want to write goes in between these quotations" << endl;
Notice the semicolon because we are within our main section. cout is the start of our command and the endl just stands for end line. Go ahead print whatever you want. This is the command we will use whenever we need to print something in our programs to come.

Code:
#include <iostream>

using namespace std;

int main()
{
    cout << "this is exciting" << endl;
    cout << "feel free to add as many of these as you want" << endl;
    cout << "more tutorials soon" << endl;
    system("pause");
}


William Surmak
William Surmak

Posts : 104
Join date : 2011-10-12

Back to top Go down

Into to Programming Empty Re: Into to Programming

Post  ljking Thu Jan 15, 2015 5:52 pm

If you are happy with Visual Studio, you can also use it for Android development. Just add vs-android to visual studio.

vs-android is here: https://code.google.com/p/vs-android/  Follow all of the instructions in the Install wiki, then download the samples. One of the samples is the triangle drawing program I showed you on Tuesday. Once you get everything setup correctly between the DragonBoard and the development system, just run a build, it will compile the code and download the apk to the Dragonboard. It took me a whole day to get all of the things setup correctly (I had problems reading), but I think I can remember the solutions to the problems (and we did update the Wiki as I did it) so let me know how it goes.

ljking

Posts : 12
Join date : 2014-12-10

http://mydragonbaord.org

Back to top Go down

Into to Programming Empty Re: Into to Programming

Post  Sponsored content


Sponsored content


Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum