Embedded System - Raspberry Pi
In this tutorial, I will show you how to create a very simple C program and compile & run it on Rasphberry Pi. Once this is done, all of the remaining thing would be to study about C language itself. It is nothing to do with Raspberry Pi. Refer to my notes on C for the details of C language itself.
Before you start trying this tutorial, first make it sure that your Raspberry pi OS is installed with gcc as shown below.
Run a text editor tool and create file (In this tutorial, I used nano editor and created file named helloworld.c). To do this just type in following command on command line.
# sudo nano helloworld.c
Then you will get a editor program opening as follows.
Write a program as you like. (I tried my favourite Helloworld)
Save and Exit the editor. To do this, try folowings
i) Press Ctrl + X (meaning Exit), and you will get the following menu as shown at the bottom
ii) Press Y (meaning Yes). Then you will get the following menu at the bottom
iii) Press Ctrl+T (meaning ToFiles), then you will get the list of files shown as below.
iv) select the file name (helloworld.c) as shown above and hit Enter.
List the files in the directory and see if the source code file is created as shown below.
Compile the source code as shown below.
Check if the compiled program is created as shown below.
Test the program as shown below.