Index
- Index, introduction and tools
- Compiling process
- Explaining our first C program
- Basic data types
- Variables
- Variables: working with character strings
- What are pointers
- Code flow
This humble tutorial is dedicated to all those that want to start learning programming. I'll be using the C programming language to introduce programming concepts, show some examples and proposing some exercises so you can practice the concepts involved.
I'll be focusing on standard C, and for this I'll suppose you're on a POSIX machine (e.g. Linux). The code should work as well on Windows, but I'll not address any problem specific for this platform, nor provide tools or compilers. Search for yourself, read the documentation or check with Microsoft support if you're having problems with the tools/code presented here.
Installing the required software
We basically need 2 things: the C compiler suite and a text editor.
The C compiler suite comes in the build-essential package for Linux distros. You can search for the package name on your distro's package manager and install it with full dependencies.
On Debian-based systems you can simply execute the following command as root on a terminal:
Code: Select all
apt-get install build-essential
Code: Select all
m0skit0@soviet:~$ cc
cc: no input files
The text editor can be anyone, although I strongly suggest using a text editor that supports programming features (e.g. syntax coloring, automatic formatting, etc...). For this tutorial I'll be using gedit, the default GNOME text editor.
You can alternatively use an IDE, but setups and configurations differ much, and I'm not going to cover this here. I personally use Eclipse.
Checking the environment
Ok time to write and compile our first program to check if everything installed successfully.
First, we're going to copy the next code into our text editor and save it as foo.c:
Code: Select all
#include <stdio.h>
int main()
{
printf("Hello wololo.net/talk!\n");
return 0;
}
Code: Select all
m0skit0@soviet:~/Temp$ cc -o foo foo.c
Now time to execute it:
Code: Select all
m0skit0@soviet:~/Temp$ ./foo
Hello wololo.net/talk!
See you on the next part.
<< Prev Next >>