The B Com program is a useless course

Welcome to our C course!


 
 
 

INSTALLING THE COMPILER:

The following procedure applies to those who are members of AOL. All others have to read the corresponding help texts of the respective compilers.
 

First of all, a compiler should be available. The DJGPP is located in the file library Programming / course material under the file C compiler. For all others who follow the course outside of AOL, please refer to the installation instructions for the DJGPP package to find out how to get the compiler running. For all others, the installation is simplified as described below.

Danger: After downloading, there should be at least 10 MB free on drive C: because the compiler needs approx. 6.2 MB and creates temporary files itself. Now enter the following in the DOS shell:

    mkdir c: \ ckurs

    pkunzip -d c-comp.zip c: \ ckurs

There is now a batch file ckurs.bat under c: \ ccourse which sets all the necessary variables that we need. So either in the autoexec.bat in the end one c: \ ckurs \ ckurs insert, or start the script before using the C compiler.
 
 
 

Since we have installed the compiler, we want to convince ourselves that it works flawlessly. As described above, c: \ ckurs \ ckurs Enter if the batch file has not yet started.

In the subdirectory c: \ ccourse \ course there is already our first program, which we want to use as our first learning unit afterwards.

So we enter:
 

gcc test.c

exe

If everything went smoothly, we now have a program, which one?a.exe? means, generated. What happened now With gcc test.c we started the compiler and told him that we were running the program test.c want to compile. Here we already notice: The compiler comes from the UNIX world:) It generates a program with the name a.out. Typically UNIX and very useless for us. So we type exe a. The program calls this batch file aout2exe on. You can do that directly, but it's shorter.

The resulting program a.exe is our executable program.


 
 

Compiling our program on Linux is similar. Almost even easier. Since the GCC is already integrated in the basic system, we only need to look at the compiler call.
 

That's it. The compiler compiles and links our program in one go test.c and creates the executable program test. This can be done immediately with the call ./test are executed.

This command sequence does not work under DOS!

As a programming interface wpe in terminal mode, or xwpe recommended under X-Windows. They largely correspond to the Borland compilers.
 
 

What actually is RHIDE?

Rhide is a development interface like Borland C's. Practically not? The program is freeware. The copyright lies with Robert Hoehne. You can find the current version under or in the AOL programming forum (password: programming) under course material.
 
 
 

And off we go with our first C program!

First of all, of course, we should take a look at what is in the program:
 

    / * This is our first C program in the AOL C course * /

DANGER! C distinguishes between upper and lower case!
 
 
 

In our first program we can already see all the features of a C program. Comments are enclosed by a / * at the beginning and a * / at the end. The compiler skips everything that is within this comment:
 

    /* This is a comment */

The command #include indicates that a program collection is to be integrated into the program. C is a programming language that is basically made up of just a few commands. This is one of its great strengths, as you can program your own commands later. But that also means: Even basic functions such as screen output or keyboard input are small subroutines that have to be explicitly integrated, otherwise the compiler does not know what to do. Conclusion: C has a modular structure. From the ground up! With the #include we will go into more detail in a later chapter.

Now we come to the most important module, which should definitely not be missing!

The main module. It tells the compiler that this module represents our program. If it were missing, the compiler would not even know which the main program is and would therefore only generate program modules without making us happy with even one working program.

All other modules that we will write later can only be executed if they are called directly or indirectly from the main program!
Each module consists of a module name and a body. The module body is represented by two curly brackets. Everything in these brackets belongs to the module.
 

Module ()

{

/ * This is the content of the module * /

}

Granted, this module is pretty useless as it only contains one comment line. As already described above: A module name is distinguished by all the others: main () !
The double brackets behind the module name are mandatory because transfer parameters can be found there. We will make use of this later when we take a closer look at the modules
 
 
 

Back to our program: the only command we use here is the? Printf ()? Command. As already mentioned, this is itself a module that is given what is to be displayed on the screen.
 

So it should be the text AOL C course output on the screen. Each command line must end with a semicolon so that the compiler knows when the command is finished. Now, of course, comes the justified objection: What's that supposed to mean? \ N? There ? Certain characters such as \ or% are reserved characters that tell the compiler that certain actions are to be taken here. ? \ n? says: A line feed is inserted at this point. Otherwise, no new line would simply be started after the text.
 

printf ("AOL");

printf ("C-Course \ n");

So is the same as what we did with our one line above.
 

printf ("\ nAOL C-Course \ n \ n");

So the upper one would first output a line feed, then our text and two line feeds on the screen. The best thing to do is to try it out.
 
 


 
\ nLine feed, corresponds to RETURN when entering the keyboard
\ tTabulator, a tabulator [TAB] jump is made on the screen
\ bBackspace, the last character is deleted
\ rCarriage return, irrelevant under UNIX. Under DOS, the end of a line consists of \ n \ r
\ fIrrelevant for screen and keyboard, causes a formfeed under a printer output
\0NULL, is used internally for a string end marker. Sometimes also used with printer sequences.
\\Backlash, creates a \ on the screen
\'Creates an apostrophe on the screen
\"Generates quotation marks, which are otherwise difficult to display

 
 

So much for the first part of our C course! Of course, I will not leave the whole thing alone without practice. If someone has questions about understanding, please put them on the pinboard Programming / C-course talk to write. In this way, several people with similar problems can be helped and there can also be constructive cooperation between all of them!

Here we go:

1) The following string should be output with quotation marks. "C is fun"

2) The same should be output without quotation marks, but with a line feed between each word.

3) Just experiment with the special characters that start with.

Have fun. Next time we will deal with variables and reading them from the keyboard.
 
 
 
 

Author: Sebastian Cyris \ PCD Bascht

This C course is for teaching purposes only! Reproduction is prohibited without prior agreement with the author! The software used is subject to the GPL and is subject to the terms and conditions attached to the software for its use! Each additional license agreement that is enclosed with the software used must be observed!