The C Programming Language (NPRG066)

NPRG066, MFF UK, summer semester 2020/2021.
Malá Strana, Wed 9:00, room SU2.
The seminar is lectured remotely over Zoom until further notice. All students who signed up were sent email with the Zoom link. The link is also on the table board for this course in the MFF UK information system.
Lectured by: Jan Pechanec, Vladimír Kotal
Department: SISAL
First class: Mar 3, 2021

Overview

"Since C is relatively small, it can be described in a small space, and learned quickly. A programmer can reasonable expect to know and understand and indeed regularly use the entire language."

-- Brian W. Kernighan, Dennis M. Ritchie

The seminar is lectured in English unless everybody present can speak Czech. It is a recommended pre-requisite for Unix/Linux Programming in C (NSWI015).

Abstract

The hands-on seminar is meant to teach students how to program in C. It is targeting people who have no prior experience with the language. The seminar is not an introductory programming class. It assumes some familiarity with basic programming concepts like variables, assignment statements, loops, and functions. The C standards C90 and C99 will be covered. Strong emphasis will be put on writing real C programs taking advantage of all the language features discussed.

Target Group

This seminar is primarily targeting people who have no prior experience with the C language. However, anybody is welcome, especially after the first elementary lectures.

Development Environment

What you need for this seminar? Just a C compiler and a text editor. There are a few options:

  1. Linux machines in the SU2 lab remotely accessible via SSH with your MFF UK login. The compiler is gcc. Start a few terminals and that is all you need. To log in, use e.g. ssh yourname@u-pl3.ms.mff.cuni.cz. There seems to be u-pl machines from 1 to 37. Pick any of those, your home directory is mounted on all. You can use PuTTY client on Windows. Windows 10 already have OpenSSH.
  2. Use your laptop with a GNU C (gcc) compiler installed, or any other modern C compiler. Any Linux distro, (Free|Net|Open)BSD, or a macOS machine will do but you may need to install the compiler there. On macOS, just run cc and follow the instructions there.
  3. Install a C compiler on your Windows laptop.
  4. Various combinations of the above in a virtual machine (e.g. open source VirtualBox runs on many platforms).

Development Tools

We recommend to work from the terminal only, there is really no need for an IDE. We use ViM (on Linux distros and macOS as vi) and the compiler. If you are in the first year and did not go through the Unix intro lecture yet, the vi editor may not feel friendly at first, in that case Joe is a good alternative. It is also installed on all Linux lab machines as joe. You can also use GNU nano which is very easy to use as well.

If you can create a simple C program, compile it, and successfully execute the resulting binary a.out, you are good to go. For example:

$ cat main.c 
int
main(void)
{
}
$ cc main.c
$ ./a.out 
$ echo $?
0

Mailing List

Subscribe here to c-prog-lang-l mailing list hosted on mbox.ms.mff.cuni.cz.

We will use this alias for various announcements regarding the seminar. It is your responsibility to subscribe to it. And feel free to use it for technical discussion regarding the C language and what we do in the seminar.

Syllabus

Getting credits

To get credits, you complete a given assignment in C as a home project. The project submission is via sending us email with a link to an online repository we can use with Git or Mercurial (e.g. GitHub). You need to send the email to both of us, see the contacts below. Sending your code as an attachment will not be accepted.

We need to receive the email before the deadlines, anything after the deadline will not be accepted.

You must pass all the tests before handing over your solution. The tests will be provided with the assignment. We will build your code and verify the tests on one of the Linux machines u-plN in the MFF UK lab at Malá Strana, see the Development Environment section above. If your code does not pass all the tests there, the submission will not be accepted.

You are supposed to write the code by yourself. Taking any existing code is strictly prohibited except for copy/pasting the POSIX tar structure as specified in the assignment.

The assignment has two phases. First has a deadline of Sun Jun 13, 2021, 23:59:59, CEST (= local Prague time), the 2nd has a deadline of Sun Aug 1, 2021, 23:59:59, CEST. Please note that the deadlines are hard and failing them means you are forfeiting your chance to get the credits for this year.

Obviously, you can send us the whole thing in one step before the first deadline, no need to separate the project in two parts.

If you need to finish your semester earlier (that may apply to Erasmus students), you need to finish the 2nd assignment in full before that.

The assignment for both phases.

Seminar Notes

Seminar repository is work in progress. There is a direct link to the generated notes. A HTML version of the notes is provided as well.

C style for writing code

We strongly encourage you to use a good C style to follow when writing C code. It comes with a Perl script to check your style. We just cannot stress enough the importance of readable code with a unified look.

There are other indent styles to choose from.

References

Primary References

Supplementary References


Last modified: