Remember in elementary school how there was always that one topic that the kids in the grade above would warn you about? They’d whisper horror stories about learning multiplication or cursive (am I aging myself here?) at the bus stop, sending a chill into the students in the grades below.
Recursion is that topic for many programmers. It comes in whispers and horror stories. But the thing is, just like cursive and multiplication, it becomes much easier with practice. Don’t get me wrong — I still have to practice explaining it out loud in order to understand what I’m doing…
When working on large projects, it can be frustrating to compile many files together. This is even more of an issue when sharing the files with others. Libraries enable us to organize and use functions without having to copy the source code into each location.
If you’ve done any programming in C, you’ve likely begun your file with something like
When you do this, you are calling the header function for the standard library. Each of the files in the standard library exist as source code, but you don’t have to compile them into your file because the…
When you open a terminal on your computer, it will begin to run the shell program. A shell is a program that interprets and executes commands from the standard input or from a file. If you’re using a Linux-type system, your default will be a bash shell. However, there are several different shells available, and you can even create your own!
To better understand the shell, let’s dig into the ls -l command to see each step of its process.
When you first enter the shell, it prints a prompt. When you type in ls -l, the shell uses the…
You’ve done it: you worked tirelessly on a series of functions to plug into your main file, but now you’re typing a rambling stream of files into your command line to compile them together. There has to be a better way, right?
A library is a single file that contains any object files that are needed for a project. During compiling, the linker uses a library to access several object files as one item.
There are two different types of libraries in a Unix system. A static library (also called an archive) is an indexed library that is…
Before using any C program, it is essential to first compile it. While a simple
will compile your code for you, it’s critical to understand the steps that it takes to make your program executable.
Steps of Compilation
The preprocessor will format your program for the compiler. To do so, it removes comments, includes header files, and performs macro expansion.
To send a file to the preprocessor but not compile it, we will use this command:
gcc -E [filename.c]
The compiler takes the output from the preprocessor and turns it into assembly code.
What do you do when you only want to see the c files in your directory? With a simple string, you can filter only the desired files to your list.
How does this command work? Let’s start at the beginning of the string.
The ls command lists directory contents. When used alone, it will display the names of all contents that are not hidden (starting with a period).
The * acts as a wildcard, instructing the command to match certain patterns. When used on its own, an asterisk will select every item in the current directory…
When linking files in a Linux system, it’s important to think about your goal. Are you trying to save an exact copy of the file? Are you trying to make it easier to reach in a different directory?
Depending on these goals, you will want to use either a hard link or a soft link. While both will direct you to a file, they serve different functions and may lead you to different versions of a file.
A hard link is an exact link to a file’s inode. This means that even if you change the content of the file…
Software engineering student and lover of mountains.