![]() ![]() Now open up a command prompt and navigate to the directory that contains the file. ![]() So, take the above code and paste it into a file called 01_HelloRPi.cpp. ![]() ![]() If you change the text in between the two double quotes, you can make the computer write anything that you want to the screen. The first one writes the phrase given to the screen, and the second one tells the computer that the program succeeded. Inside the function we only have two lines. The curly braces signify the start and end of the function. It lets the computer know where your program starts, so every program must have a main function. The main function is a very special function. This is used to let other programs know if the program succeeded or failed. This function is called main and it doesn’t take any inputs, so there are just empty parenthesis after the name of the function. The function would take in an angle, do some computations on that angle and then return the sine of the given angle. A simple example would be a sine function. A function is a group of code that takes a set of inputs and produces an output. This line tells the computer that if it is looking for a function, that it should start by looking in the std namespace. If I tried to call that function the computer wouldn’t know which one I wanted, so to help with this namespaces were created. Imagine if I wrote a function called foo and someone else wrote a function with the exact same name. This is to help fix name collision problems. The next line makes it so that you don’t have to prefix the functions in the library with the name of the namespace that it is in. Many common functions, such as writing a message to the screen, have already been written, so you can just reuse them and focus on aspects of your program that are unique to the problem that you are trying to solve. Libraries are prewritten code that you can leverage to do things faster and easier. Here’s the code to print out a message to the screen: Raspbian comes with all of the tools that we need to start programming, so let’s dive in. It’s very easy to install and set up and it seems to be the most popular OS for the raspberry pi. Setupįor this tutorial series, we are going to be using the Raspbian OS. By the end, you should have a great foundation in c++ that you can use to build your own projects. Occasionally, we will take a step back and use what we have learned so far to do a project, so that you can exercise the skills that you have learned and build something exciting. This tutorial series will start with the basics and then quickly move on to more advanced topics. So, in this tutorial series, we will be taking advantage of these enhancements. So, what do I mean when I say modern? In August of 2011, a new version of the c++ standard was released that included some exciting new features. In this tutorial series, we are going to learn modern c++ using the raspberry pi. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
December 2022
Categories |