Why Some Programmers Treat C ++ as C

Introduction to programming II - SS 2004

[an error occurred while processing this directive]

Information on the C programming language

Most of the programs that will appear in the lecture and exercise will work both as C and C ++ programs with at most minor modifications - only towards the end of the semester will language elements be discussed that are only available in C ++, but not in C. Nevertheless, it is recommended to use a C ++ translator from the beginning, this will save one or the other confusion.

C / C ++ translator:

The essential program that we need is the compiler, which translates our C ++ program into a sequence of machine commands on our computer.

Otherwise we only need a text editor to get our programs into the computer - under Windows e.g. Notepad or Wordpad; not Word and the like, which are intended for creating formatted text, the required file format is "plain text".

Linux and Unix

A C ++ compiler will practically always be installed on Linux or Unix computers (e.g. in the SUN hall). We will be using the C ++ compiler from the GNU Compiler Collection (GCC). This is usually called with the command.


There are some free C / C ++ translators for Windows and DOS, e.g .:
  • DJGPP is a DOS version of the GCC compiler and behaves very similarly in terms of operation.
  • [absolute C beginner] is a website that describes the installation of various freely available C compilers, e.g. the DJGPP:
    there is a separate page for Download the DJGPP (unfortunately apparently out of order at the moment, so take the general DJGPP page), as well as to Installation of the DJGPP.
  • Cygwin is a Unix-like interface for Windows (including the C compiler); therefore a bit more complex to install, but also more convenient
Further information on C / C ++ compilers can be found in the C-C ++ corner (see below).

Enter and run C programs

A very brief description that deals with the normal case (C ++ programs under Windows or Unix) - details can vary depending on the system.

  • Enter the source text (the C program) using a text editor (Windows e.g. Notepad or Wordpad, Unix e.g. - if available - nedit) and save it ("Text only")
    • Filename: should be replaced by a meaningful name ...
    • For starters it may be helpful to have a ready-made file to try out the following steps: Here is the program from the slides with the for loop:
    • After every change of the program: don't forget to save :-)
  • Compiling (i.e. creating an executable file for the computer from the C program that we can read). For the time being, the simplest variant does it (of course, replace blub with the program name again)
    • Windows:
      • Open command prompt, change to the directory in which our program is located ()
      • Control: ours should now be listed with
      • (or whatever our program is called)
      • Control: should now list a file (often also one)
    • Unix:
      • Open the terminal window, change to the directory in which our program is located ()
      • Control: ours should now be listed with
      • (or whatever our program is called)
      • Control: should now list a file
  • To run:
    • Windows (command prompt):
    • Unix (terminal window): - if that doesn't work, try it

Literature on C / C ++:

Fills entire shelves in bookstores. A pure C-book is sufficient for our purposes; if you buy a C ++ book, make sure that it covers the basic concepts of C (as opposed to: object-oriented programming) extensively.

In libraries, make sure you have a book about ANSI-C borrows; a book explaining the older C variant is likely to confuse more than help. Sometimes old and new versions of the same book title are available, so you have to be careful. On the other hand, the risk of getting a non-ANSI-C book turned on in the book trade is extremely low.

Recommended literature

  • Brian W. Kernighan, Dennis M. Ritchie: Programming in C. ANSI C. Hanser publishing house.
    Although this book is more of a language reference than an introduction to C programming, this book has lasting value as a reference work.
  • Ulrich Kaiser, Christoph Kecher: C / C ++. From the basics to professional programming. Galileo Computing.
  • Just for reference (as there is no textbook), but cheap: The programming language C from the regional computing center for Lower Saxony (RRZN), which you can buy in the user office of the LRZ.

Online material:

The various works in electronic form are even cheaper, e.g. the following:


Notes on Unix and computing in the IT hall

An introductory guide to Unix is ‚Äč‚Äčavailable from the LRZ user office.
Stefan's room