CS50x : Week 2 : Arrays

In Week 1 I learnt the basics of C programming language. This week I will learn about the data structure Array.

Firstly I learnt about how a compiler works and what compiling is. It involves 4 major steps: Pre-processing(header files are copied and pasted into our file), Compiling (program is converted to assembly code), Assembling (assembly code is converted to Machine code(0s and 1s)), and the last step is linking where code from the included libraries is also converted to machine code and combined with our code and an executable file is outputted.

Next, I learnt about debugging. We can use printf() function to debug our code but a more useful method is using software called a debugger which helps us iterate through every step in our code and discover the errors aka bugs.

Next, the concept of Arrays was introduced. Arrays are a way of storing data back-to-back in memory, that is it is a sequential data structure. Elements are added and read sequentially.

Next, I learnt how string is an array of characters, and then we learnt about the different operations one can do on and using strings by defining it as an array. Then, I learnt about Command-Line Arguments and how they can be used in a terminal. We can pass CL As by replacing

int main(void)

with:

int main(int argc, string argv[])

This helps us provide variable-length arguments which makes program execution less tedious.

Finally in the end I learnt about what exit statuses are and how they can be useful in real-world scenarios to detect errors and understand and troubleshoot them. Next, there was a brief introduction to Cryptography where text is encrypted and decrypted. Cryptography seemed very interesting and amusing to me. It is crazy how the technology of end-to-end encryption is accessible to common people through messaging apps like WhatsApp Messenger and Signal Messenger.

Thus to conclude, this week we learnt a lot about how exactly a compiler works, debugging, arrays, strings, arrays operations, command-line arguments and the basics of cryptography. A lot to absorb but amusing! Looking forward to learning more!