Articles Hierarchy

Articles Home » other » learn C ( on a Win 10 PC or Raspberry Pi )

learn C ( on a Win 10 PC or Raspberry Pi )

today i was asked ( by my 14 year old nephew ) how to start learning the C language

- - my first reaction was to say that this might be the most difficult and demanding but powerful language to start learn coding

- - that i actually never even try it from a windows PC ( only from Raspberry Pi Linux RPI to learn GUI programming)

back to the very basics:
a program / code is a text file with english like commands and syntax
what can be translated via a compiler ( for that syntax / language ) to create a run-able program
( .exe for windows )
if you install that compiler program for windows you would still have to work on DOS level.

to close that gap to windows environment can use a IDE

+ + with a few seconds of google search i see one way could be to use

alternative to code::blocks you might try to use ECLIPSE IDE
from eclipse get eclipse-inst-win64.exe (52MB).

the first steps:
install code blocks on win 10 PC
( see also youtube )

download for windows
see here that the newest version is from 30 Dec 2017, might have been not the smartest IDE selection.

there click on the link to get the "mingw" setup ( comes with GNU C compiler )
codeblocks-17.12mingw-setup.exe via
and see
auto download with lots of confusing advertisements links..

now find and install codeblocks-17.12mingw-setup.exe (86MB) as admin.

here see the desktop with icon and first start window:

IDE help: here
C language help here

sadly that not comes with examples, so the way to your first program
would be little bit more as a click.
video tutorial

now you can start learning C coding: variables / math / if / for / ...
but not in a lifetime you could write a program for windows, with a window , operation menu , file handling , graphic output,
for this you need to use one of the additional tools and libraries, what come with this IDE as ready templates, like:
QT , wx, GTK, win32GUI
but the tools you need to install additionally, basically the library and a window designer tool.

pls. understand that i am NOT a C programmer,
after 30 years in the industry as computer & instrument engineer,
i play many years
* C++ Arduino coding,
* Processing JAVA,
also many other things, python, web server and design...
but i am actually not qualified to make a C Tutorial!

after have the CODE::BLOCKS installation tested, by use
+ new project
+ console application
+ build
+ run

we start with our first code: a easy FOR loop to print lines

we try a keyboard input of two numbers and print out the result of a+b=

now we do same, but try to put the sum calculation and the print into one function

when we use many function with good naming our main program stays short
and is easy readable.

start to play with the TIME library, first print current time

try a C_program what prints lines every second

and a repeating timer function

get a string ( line ) from keyboard and save it in ( at end of ) a file (append)

make a program what runs forever, until enter 'e' from keyboard
declare a static / array long 10 / filled with any integer numbers
on keyboard entry 0 .. 9 print this number and also the value from the array with this as the index

now we play already variables and arrays, but how about class?
well while C++ / JAVA ... knows them C closest thing is a struct,
with this you can build a multi type record.
and making a array of struct should be something you can call database ( or table )
as used for JSON or CSV files... or after you combine it with functions ( C++ call it methods )
a class alike.

make a program what creates a record for books ( title / author / book_id )
and a array of it ( database / filled manually )
add a record print function

here we are at the end of the basic C tutorial.

lets play something different

if you dig deeper into programming languages you read that JAVA and C are very different things,
( and i not want to compare them ) but if you read some basic code snippet it looks same.
here a idea, play Processing ( JAVA ) for a few
days, not try coding, just READ over and RUN the examples.
until now in C we did actually only DOS programs, using JAVA, with Processing library,
shows the thinking how to make ( graphic ) desktop apps easily.
from Processing download ( current version for win 10 )
unzip like to a c:/users/me/Documents/
and find c:/users/me/Documents/processing-3.5.4/processing.exe ( start / make shortcut to desktop... )
at first start get created c:/users/me/Documents/Processing, your code / examples / tools ... directory
you could move from the MENU / file / preferences

MENU / file / examples // for a first test, press RUN
and windows defender will ask you to allow run JAVA

after you get a idea about creating a graphic window,
also using keyboard / mouse, draw shapes ( basic JAVA processing functions )
try the top addon library G4P:
MENU / tools / add tool // libraries / G4P and install
MENU / tools / add tool // tools / G4P GUI Builder and install
now find the added examples under
MENU / file / examples // contributed libraries / G4P /...

last exercise of that short side step to Processing JAVA is, run the
MENU / tools / G4P GUI Builder
and make a button, save the created code and run it.

desktop app

back to CODE::BLOCKS and language "C": now if we look at the provided templates

there are a lot what can be used for desktop apps ( creating a desktop program window under win or linux )
top might be QT what requires that that is installed additionally, we should try the open source / community / free version from

but we start what might be the entry level:
win32 GUI project
understand that with this you might understand the first steps of desktop program development, but serious projects might never be done with it,
so after learning that ( with the required design tools ) you might later consider it as a waste of time.

now we try the C language from Raspberry Pi

here work with
DEBIAN buster
Linux version 4.19.97-v7+
Raspberry Pi 3 Model B Rev 1.2
date: Mon 2020-03-16 15:26:22

-1- just from command line ( as compiler GCC is preinstalled )
info here and here

in some work directory from terminal:

nano hello-world.c
( paste code from original code ::blocks example )
cat hello-world.c
gcc hello-world.c -o hello-world
chmod +x hello-world

Hello, World!

-2- or use ( pre-installed ) GEANY

-3- or install code_blocks under linux too.
sudo apt install codeblocks

-4- try QT5
( make sure have 2GB free )

sudo apt install qt5-default
sudo apt install libxext-doc default-libmysqlclient-dev firebird-dev libegl1-mesa-dev libgl1-mesa-dev libpq-dev libsqlite3-dev unixodbc-dev

sudo apt-get install qtcreator
sudo apt install qtbase5-examples qtbase5-doc-html