Day 2 Programming Basics / Tag 2 Grundlagen der Programmierung

in #development6 years ago

Bild1.png

Content

Developer tools

Editors and compilers

Compile

and run a C program

The most important developer tools

If you want to make executable from C source code, there are two ways to do it:

The complicated variant

  • You type source code into an editor and save it. Then you translate this source code using a compiler. The result is a file with an extension * .obi or * .o. Finally, you connect this object file with a linker and an executable file is created.

Known editors:

Windows Notepad+++
vi and Emacs (Linux/Unix)
TextMate (macOS)

The all-in-one variant

  • You work with a development environment. There are a number of tools in this software that make programming easier for you as you do not have to switch from program to program. In addition, there is often a debugger with it, which detects errors when creating and tells you.

Of course, a software developer will usually work with a development environment. But in order to learn what's really going on in programming and without distraction, the complicated version is usually recommended first.

I recommend this C11 standard compiler:

gcc aus der GNU Compiler Collection (Linux)
MinGW (Windows)
PellesC (Windows)
Clang LLVM (macOS)

Compile and execute a C program (under macOS)

1. Develop

  • II take the editor TextMate under macOS and develop a small program, which should give me "Hello world" at the start. And save it under helloworld.c.
#include<stdio.h>

  int main()  {
         printf("Hello World\n");
         return 0;
}

2. Compile
Helloworld.c becomes helloworld.exe, an executable file.

compilieren.jpg

3. Start
By entering open helloworld, the program is started. If no programming errors have been made, the program will work as expected and will output "Hello World".

start.png

So you see, it's not that hard. As with the Day 1 article already said; the basic principle is always: input - processing - output.

Thank you for reading!

-Faxe

-----German / Deutsch-----

Inhalt

Entwicklerwerkzeuge

  • Editoren und Compiler

Ein C Programm kompilieren und ausführen

Die wichtigsten Entwicklerwerkzeuge

Wenn mann aus C-Quellcode eine ausführbare Datei machen möchte, gibt es zwei Wege dies zu tun:

Die komplizierte Variante

  • Du tippst Quellcode in einen Editor ein und Speicherst es ab. Anschließend übersetzt du diesen Quellcode anhand eines Compilers. Es entsteht eine Datei mit einer Endung *.obi oder *.o. Diese Objektdatei verbindest du schliesslich mit einem Linker und eine ausführbare Datei wird erzeugt.

Bekannte Editoren:

Windows Notepad+++
vi und Emacs (Linux/Unix)
TextMate (macOS)

Die All-in-one Variante

  • Du arbeitest mit einer Entwicklungsumgebung. In dieser Software arbeiten eine reihe tools zusammen, die dir das Programmieren leichter gestallten, da du nicht von Programm zu Programm wechseln musst. Zudem ist oft ein Debugger dabei, der gleich beim Erstellen Fehler entdeckt und es dir mitteilt.

Natürlich wird ein Softwareentwickler meist mit einer Entwicklungsumgebung arbeiten. Aber um zu lernen, was beim Programmieren wirklich vor sich geht und ohne Ablenkung, wird meist zuerst die komplizierte Variante empfohlen.

Diese C11-Standart Compiler empfehle ich:

gcc aus der GNU Compiler Collection (Linux) LINK
MinGW (Windows)
PellesC (Windows)
Clang LLVM (macOS)

Ein C Programm kompilieren und ausführen (unter macOS)

1. Entwickeln

  • Ich nehme unter macOS den Editor TextMate zur Hand und entwickle ein kleines Programm, das mir beim Start „Hello world“ ausgeben soll. Und Speichere es unter helloworld.c ab.
#include<stdio.h>

  int main()  {
         printf("Hello World\n");
         return 0;
}

2. Compelieren
Aus helloworld.c wird helloworld.exe, also eine ausführbare Datei.

compilieren.jpg

3. Ausführten
Mittels Eingabe von open helloworld, wird das Programm gestartet. Wenn keine Fehler bei der Programmierung gemacht wurden, funktioniert das Programm wie erwartet und gibt „Hello World“ aus.

start.png

Ihr seht also, es ist gar nicht so schwer. Wie beim Tag 1 Artikel schon gesagt; das Grundprinzip ist immer: Eingabe- Verarbeitung- Ausgabe.

Vielen Dank fürs lesen!

-Faxe

Sort:  

ich habe ja echt keine Ahnung vom Programmieren und dank dieser Anleitung sehe ich es nun Schritt für Schritt. Wow, das hat hier noch keiner gemacht. Super @faxe ;-)

Coin Marketplace

STEEM 0.28
TRX 0.13
JST 0.032
BTC 65925.23
ETH 3003.40
USDT 1.00
SBD 3.75