Basics of C

​​​Authors

Dicaprio Cheung (dhcheungaa@connect.ust.hk)

Daniel Cheung (dcheungaa@connect.ust.hk)

Ho Yu Yat (yyhoai@connect.ust.hk)

Lau Ka Kit, Danny (kkdlau@connect.ust.hk)

Li Ka Yau Elwin (kyeliaa@connect.ust.hk)

Leung Ka Chun, Wesley (kcleungax@connect.ust.hk)

Li Chi Kin, Andy (ckliam@connect.ust.hk)

Suggested Learning Materials

Helpful playlist

For tutorial 0, watch #1 ~ #8

Legacy tutorial videos

Introduction to C, a procedural language

C is an old language. It was very popular then, and is still popular now, because of how robustly it can run. It is a low-level language, meaning there is little between it and machine code (0s and 1s). It also means that we often have to manage the memory (RAM) by ourselves, the programmers.

C is also a procedural language, where we have to give a list of instructions to the computer one by one and it follows line by line. A specific way to write the list of instructions to do something, is what we call an algorithm.

C vs C++

Both C and C++ are very similar so people might mix up these 2 programming languages.

TODO: write something here

What should I do if I get stuck while programming?

Although programming can be fun, debugging is stressful and exhausting. You may come across some bugs that you cannot solve by yourself. Here are some useful websites to use:

The easiest way to debug is to print stuff out so that you can track (1) how your values change and (2) whether your code reaches a certain line of code (e.g. maybe an if-condition failed).

If you really don't know which lines of code cause bugs, you can comment on parts of your code and run the code again to see if the bugs reappear or not.

Enjoy your time debugging!

Using AI in coding

We welcome the integration of AI in software development. Using tools like ChatGPT to generate code or debug our code in English really makes our lives a whole lot easier :) However, when using them in your programming work, you need to be aware that they only act as your assistant. They can streamline your work but you can't just blame ChatGPT if the code is not fully functional or it has many bugs. It's your job to double-check their work and fix any errors.

When you decide to use ChatGPT to generate code. It is strongly recommended that you should understand and analyze the logic behind the code. Make sure you do understand why it decides to this line of code. You should not blindly trust all the code written by AI. Not only does training your technical skills, but it can also help you document your code better.

Reference Materials

https://www-s.acm.illinois.edu/webmonkeys/book/c_guide/

Last updated