Code

C Basics: Learning the Programming Language from Scratch — Lecture 1.1 of the CS50 Course

C Basics: Learning the Programming Language from Scratch — Lecture 1.1 of the CS50 Course

Learn: Become a C++ Developer from Scratch

Learn More

CS50 (Computer Science 50) is a renowned computer science course offered by Harvard and Yale Universities. It has become an important starting point for many who want to begin their programming journey. This course consistently covers key topics such as computer logic, visual programming using Scratch, C language basics, array manipulation, basic algorithms, memory management, and data structures. It also covers the fundamentals of Python, SQL, HTML, CSS, JavaScript, and the Flask framework. This course provides students with the necessary knowledge and skills to successfully launch themselves into the world of programming and technology. By completing this course, you will gain a deep understanding of how computers work, master the fundamental principles of programming, and learn to read and analyze code in various programming languages. This knowledge will open up new opportunities in IT and will help you in your future studies and professional career. In this article, we will examine the basic principles of programming using the Scratch visual environment as an example. More complex topics, such as C and other programming languages, will be discussed in future articles in this series. Scratch provides a user-friendly interface for beginners, making it easy to grasp basic concepts such as algorithms and logic. Prepare yourself for an exciting dive into the world of programming with Scratch before moving on to more complex languages.

For successful search engine optimization, it's important to consider not only the content but also the structure of the text. SEO optimization involves using keywords that match the topic of your content. It's also worth paying attention to headings and subheadings to improve readability and increase your chances of ranking in search engines. Creating unique and informative content that addresses user queries is crucial. Don't forget about internal and external linking, which will help improve navigation and increase the authority of your resource. Regularly updating content also helps keep it relevant and increases search engine rankings. Use meta tags and descriptions to draw attention to your content, and monitor analytics to understand what changes can improve your rankings.

  • The Key to Writing Good Code
  • Using an IDE
  • Compiling a Program
  • Functions and Arguments
  • Why the Main Function Is Needed
  • Header Files
  • Linux Commands

Why We Translated CS50 and How Each Article in the Course Is Organized

CS50 is the flagship programming course at Harvard University and the most in-demand massive open online course on the edX platform. All course materials, including hands-on exercises, are available for free. You can also earn a certificate and additional benefits for a small fee. The course covers the fundamentals of computer science and programming, making it ideal for both beginners and those looking to deepen their knowledge. We've converted the video lectures into text format, adding illustrations and clarifying some explanations. All materials are open source. The original course is licensed under an Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license. This means you can remix and distribute it free of charge, as long as you adhere to the original license. Thus, you can use this series of materials in your work or social activities completely freely and gratis in accordance with the specified license.

Each article from the CS50 series includes the following materials:

  • text translation of the video (sometimes half of the video, if the topic is extensive);
  • link to the original video in English;
  • diagrams and explanations;
  • links to more detailed materials on the topic of the article;
  • practical tasks.

An American scientist and professor at Harvard University. His research in science and education has had a significant impact on the development of the academic environment and innovative approaches to teaching. Ambitious projects and publications help expand the boundaries of knowledge and inspire a new generation of researchers.

Original video

The Main Conditions for Creating Good Code

In this lecture, we will begin learning the C programming language. Unlike the visual language Scratch, C is a text-based language that serves as the basis for many modern languages, including Python. Learning C will open up new possibilities in programming and help you understand the principles of other languages.

Our main goal is not for you to master specific programming languages ​​such as Scratch, C, or Python, but to learn how to program in general. The C language is full of details that can distract from the programming process itself: complex syntax, varied punctuation—hash marks, angle brackets, parentheses, and braces, backslashes, and much more. However, I'm confident you'll soon master all of these nuances. It's important to remember that we've already covered many principles that will help you along the way.

While working through Scratch problems, we explored functions that take arguments (inputs) and return values ​​(outputs). It's important to note, however, that not all functions have return values. Understanding these concepts is a key aspect of programming, as it allows you to create more efficient and organized programs. Exploring functions with arguments and return values ​​helps improve your programming skills and deepen your knowledge of Scratch.

We discussed conditional statements, which can be thought of as forks in the road in programming. We also looked at logical expressions, which are questions with two possible answers: yes or no, true or false. These concepts are the basis for decision making in code and play a key role in managing program flow. Understanding conditional and logical expressions allows developers to create more complex and powerful algorithms.

We examined loops, which allow the same action to be performed repeatedly, and variables, which temporarily store values. These concepts will be useful later.

Now let's look at how to translate these concepts into code in programming languages. The syntax of programming languages ​​is usually simpler than in natural language, since the number of words used is significantly smaller. However, when working with programming languages, special care is required, since even minor errors can lead to program failures. It is important to understand that precision and accuracy are key factors when writing code, since a computer requires strict adherence to syntax rules.

You have written code and are wondering: is it good? The first criterion for evaluating code is its ability to correctly solve the problem. However, even if the problem is solved correctly, long and disorganized code will be considered poor quality. Another programmer will have a hard time understanding the logic of your code and its correctness. Moreover, when you look at this code in a year or even the next day, you may not remember exactly what you wrote. Effective code should not only be functional but also readable to facilitate its maintenance and modification in the future.

It is important for a programmer to focus on creating high-quality code, improving the efficiency of algorithms, and maintaining code cleanliness. Code aesthetics also play a significant role in its perception and subsequent maintenance. Clean and structured code not only makes it easier to read but also facilitates debugging and optimization, which ultimately leads to the creation of more reliable and performant software solutions.

Good code has several important characteristics, such as correctness, design (architecture and structure), and style. Let's look at a simple example of a C program that prints "Hello, World" to the terminal. This program is a great example for learning the basics of programming.

Here's what the code looks like:

«`c
#include <stdio.h>

int main() {
printf(«Hello, World\n»);
return 0;
}
«`

In this code, we use the stdio.h library, which is required for the printf function. The main function, main, prints "Hello, World" to the terminal and terminates the program. This example demonstrates the basic syntax of the C language and is a starting point for beginning programmers. Proper code structure and style contribute to its readability and usability.

At first glance, the process of repeatedly pressing keys may seem brutal, especially when the result is insignificant. However, after a few lectures and familiarity with more modern programming languages ​​like Python, you will see how this logic can be simplified to a single line of code. However, it is important to understand what is happening in the current context to gain a deep understanding of programming fundamentals. This will help you as you master more complex languages ​​and technologies.

Using an IDE

How do I print "hello, world" on the screen? You can use text editors like Word, Google Docs, or Pages to enter text, but they are not a solution for programming. These tools cannot convert text into binary code that a computer can understand. Programming requires the use of specialized languages ​​that allow you to create instructions for the computer to execute. To correctly display "hello, world" on the screen, you need to use a programming language that converts text into a machine-readable format.

There are tools that can significantly simplify the development process. They are called integrated development environments, or IDEs. One of the most popular examples is Visual Studio Code (VS Code), which offers many features for working effectively with code.

VS Code window Frame: CS50 / YouTube

Above is an empty file named hello.c, where the .c extension indicates that this is code in the C programming language. The line numbers displayed on the left help you navigate the program structure.

Now I'll add the stdio.h library, which we'll talk about in more detail later. Then I'll type int main(void), which we'll come back to later. After that, I'll type curly braces and press Tab to indent. Finally, I'll write printf(«hello, world\n»); and put a semicolon.

David in front of his slides while reading the course. Frame: CS50 / YouTube

Now you need to press the Ctrl key combination + S to save the file. And now I've become a programmer.

Compiling the Program

My program is saved in a file called hello.c. Now I need to convert the source code, which is text in a programming language, into machine code, which consists of zeros and ones. It is this machine code that is executed by the computer. The process of converting source code into machine code is called compilation and is an important stage of software development.

I'm not going to do this manually. There are algorithms implemented in special programs that automate this process. These programs are called compilers. Not all programming languages ​​use compilers, but the C language is one of those that actively uses this technology. A compiler converts code written in C into machine language that can be executed by a computer. This allows developers to efficiently create and optimize their applications.

At the top of the screen is a text editor that makes it easy to create files and write code. At the bottom of the screen is a terminal window where you can enter and execute commands, such as compiling source code to machine code. This is a convenient interface for developers, allowing them to effectively work with projects and manage the development process.

To convert the hello.c file into an executable program, open a terminal and run the command make hello. Then, to run the program, type ./hello and press Enter. These commands will allow you to compile and run your C program.

Building and running a C program Frame: CS50 / YouTube

The make hello command is responsible for building and program compilation. ./hello is used to run a program named hello, which is located in the current directory. These commands are key to working with software in a development environment, allowing developers to effectively manage the process of creating and running applications.

Now I'll open the integrated development environment (IDE) sidebar. This feature allows access to various tools and settings, improving the development process and simplifying project navigation. The sidebar allows you to quickly find files, manage dependencies, and view errors, which significantly increases the programmer's efficiency.

Explorer in VS Code Frame: CS50 / YouTube

I opened an application called Explorer, which displays all the files in my account. Among them is a file called hello.c, which is highlighted because it is open in our integrated development environment (IDE). Another file, called hello, was created during the compilation process. This file is executable, allowing it to be run directly.

To make changes to the program, for example, to make it output "hello, CS50", you need to edit the code in hello.c. You should then recompile the file to produce the updated hello executable. Only after compiling will the changes in the program's output take effect.

Functions and Arguments

Functions and arguments play a key role in Scratch programming. Functions represent actions, such as "speak", "call", and "call". or "ask" that the program executes. Function arguments in Scratch are typically displayed as small white oval shapes. Understanding these basic concepts will enable you to create more complex and interactive projects, improving your programming and logical thinking skills.

Let's consider our C program in the context of Scratch. C uses the printf function to print text to the screen. In this case, the parentheses represent the white oval shape used in Scratch. It's also worth noting that C uses double quotes, which are absent in Scratch; they are required when a string is passed as an argument to a function. The code also uses a semicolon, which in C terminates expressions and marks the end of a statement. Therefore, understanding these elements will help you better understand C programming and transfer knowledge from Scratch.

Functions can return different types of output, including strings, characters, and numbers. However, output can also appear as "side effects." This includes visual or audio perceptions, such as images, sound, or text that appears on the screen. It is important to understand that functions not only calculate values ​​but can also interact with the user through a graphical interface or sound notifications. This extends the functionality of programs and allows for the creation of more interactive applications.

In Scratch, there are functions that, in addition to side effects, can return values. For example, the «Ask» block allows you to ask the question «What is your name?» and stores the answer in a special variable «Answer». This value can be reused, unlike side effects, which appear on the screen and disappear. Using return values ​​makes code more efficient and convenient for further use.

The most suitable analogue for the «Ask» block is the get_string function. This function returns the result as a variable, which allows it to be used repeatedly. This way, you can effectively manage data and integrate it into your project, streamlining the process of working with information.

Function for entering user data into the program Frame: CS50 / YouTube

In C programming, the = sign does not denote equality, as in mathematics, but is an assignment operator. It is used to assign the result of a function to the answer variable. This function prompts the user for a value, which is then stored in the specified variable. Understanding the differences between mathematical and programming operations is important for successful C programming.

In the C programming language, you don't simply assign a variable a name, as in Scratch. It is important to tell the computer upfront what type of data the variable will store. For example, the string type is designed to store string data, and the int type is designed to store integers. There are other data types that we will look at later. Understanding data types is a key aspect of C programming, as it affects how data is processed and stored in memory.

If a program specifies that a variable is of type string, the computer interprets the zeros and ones stored in it as words or sequences of characters, including empty strings. If a variable is declared as an int, the data will be treated as integers. If you attempt to insert a string into a numeric variable or vice versa, the system will display an error message. It is important to understand that all data entered into the terminal, regardless of its format, will be treated as text strings, that is, as the string type. This must be taken into account when working with variables in programming to avoid errors and ensure correct data processing.

Data types in the C programming language play a key role in software development. They determine how information is stored and processed in memory. In C, there are several main categories of data types, including built-in and user-defined.

Built-in data types include integers, such as int and long, and floating-point numbers, such as float and double. Each of these types has its own characteristics, such as the size in bytes and the range of values ​​they can take. For example, the int type typically occupies 4 bytes and can store values ​​from -2,147,483,648 to 2,147,483,647.

In addition to built-in types, C also provides the ability to create custom data types using structures and unions. Structures allow you to combine different data types into a single logical unit, which is especially useful for working with complex data. Unions, in turn, allow you to store multiple data types in a single memory area, saving space.

C also has a pointer data type, which stores the addresses of other variables. This allows for efficient memory management and the transfer of large amounts of data between functions without having to copy it.

Proper use of data types in C is critical to efficient programming and optimizing application performance. When choosing a data type, it is necessary to consider not only the size and range of possible values, but also the specifics of the problem being solved. Understanding the different data types and their characteristics will help developers create more reliable and performant applications.

  • bool — Boolean values ​​(true/false);
  • char — a single character;
  • float — floating-point/point numbers (fractional numbers);
  • double — longer floating-point/point numbers (fractional numbers);
  • int — integers;
  • long — large integers;
  • string — string data.

These types facilitate the interpretation and processing of sequences of zeros and ones, turning them into meaningful data of a specific format.

Now let's look at the line feed character \n. Let's open VS Code and return to the "hello, world" example program. Let's remove the \n character and run the code for compilation and execution.

Program output without /n Frame: CS50 / YouTube

The $ sign remained on the same line with with the text "hello, world", which allows us to conclude that the \n character is used to move the cursor to a new line. The absence of this character makes the output text less structured and visually untidy. Correct use of \n promotes better perception of information and improves the readability of the code.

Now let's make the program more interactive. First, it will ask the user for the name and then greet them. This will add an element of personalization and make the interaction more pleasant. The interactivity of the program will improve the user experience and increase its appeal.

The updated C program will be an improved version that will contain optimized code, increased performance, and bug fixes. This version takes into account the latest changes in language standards and improves algorithms for more efficient data processing. The program update also includes an improved interface, which makes user interaction with the application more intuitive and convenient.

Key features of the updated C program include algorithm optimization, fixes for known vulnerabilities, improved documentation, and usage examples, which will help users quickly master the application's functionality. The updated version of the program will become a reliable tool for developers, enabling them to create higher-quality and more productive applications.

The new program and the result of its execution Frame: CS50 / YouTube

In this text We'll review the program and its structure, highlighting key points. The cs50.h library is included, which is necessary for using certain C functions. While some functions are available by default, most require the corresponding libraries to be included. The get_string function, developed specifically for the CS50 course, allows you to receive user input in the terminal. Without this function, the code would be significantly more complex and confusing. To use get_string, you must include the cs50.h library, which contains this function. This simplifies user interaction and makes the code more readable.

A library is a set of useful code fragments pre-written by programmers that can be called as functions using short names, such as get_string. The standard library stdio.h is an integral part of the programming language and provides basic functions for working with input and output. It is important to understand that even the simplest functions of the programming language are based on code written by other developers. Using libraries can speed up the development process and improve code quality because they contain proven solutions for common problems.

Our program uses two libraries. These libraries provide the functionality necessary for the application to function effectively. Each plays a vital role in implementing various tasks, from data processing to user interaction. Using these libraries can significantly simplify development and improve productivity. We recommend reviewing the documentation for each library to gain a thorough understanding of their capabilities and how to use them in your project.

  • stdio.h is a library that gives you access to printf and other input- and output-related functions.
  • cs50.h is a library that provides access to functions not found in the standard C library and includes get_string.

The CS50 library includes many functions that simplify software development and promote learning programming. Key library functions include input and output management, array handling, strings, mathematical operations, and user data handling. It provides convenient tools for implementing algorithms and data structures, which makes the learning process more accessible and effective. Using the CS50 library allows students to focus on solving problems rather than low-level programming details, which promotes a better understanding of the fundamentals and principles of software development.

  • get_char()
  • get_double()
  • get_float()
  • get_int()
  • get_long()
  • get_string()

Input functions allow you to get different types of information from the command line. If you need to enter a string, use the get_string() function. It will prompt the user for text in the terminal and store it in the specified variable. Note that even numeric values ​​will be interpreted as text strings.

The %s sign in the C programming language is used to format strings. Unlike Scratch, where strings are simply concatenated by writing them, in C you need to use special syntax. To insert a variable's value into a string, we place the special character sequence %s within the text within double quotation marks. This tells the compiler to substitute the value of the variable whose name follows the string in parentheses. In this case, it's the answer variable, whose value will be substituted for %s. This approach allows for flexible control over data output and the creation of dynamic messages.

There are other special character sequences besides %s. These characters play an important role in text formatting and data manipulation. They allow information to be displayed correctly and provide a convenient way to present data. It is important to know how to use these sequences correctly to achieve the best results in programming and web development.

  • %s — string;
  • %i — integer;
  • %f — float and double;
  • %li — long integer;
  • %c — char.

The syntax to be aware of is the following: put the string in quotation marks, inside which we use %s. After the string, we specify the name of the variable whose value will be substituted for %s. This approach allows you to effectively format strings and dynamically insert data into text.

The printf function takes two arguments. The first argument is a string enclosed in quotation marks that specifies the output format. The comma following the string separates it from the second argument, which is the answer variable. It is important to note that the comma inside the quotation marks is part of the string and does not affect the number of arguments passed to the function. Understanding the structure of the printf function arguments is essential for correctly generating and outputting data in the C programming language.

Syntax highlighting is an important feature that significantly facilitates the programming process. In the VS Code editor, different code elements are highlighted in specific colors, allowing programmers to navigate the text more quickly. For example, the string_answer variable is displayed in black, the get_string function is brown-yellow, and %s is blue. This color distinction helps developers easily identify different code entities. Black indicates variables, brown-yellow indicates functions, and blue indicates special characters. Syntax highlighting is present in all modern code editors and integrated development environments (IDEs), making it an indispensable tool for programmers.

Note the indentation on lines 6 and 7. I configured the VS Code editor to use four spaces when pressing the Tab key, which is a common practice. Proper indentation helps visually emphasize the hierarchy and nesting of code elements. Elements that are at the same level are indented equally, for example, opening and closing braces. If one element is nested within another, it is indented according to the indentation of its parent element. For example, the declaration of the string_answer variable is located inside the main function. Proper use of indentation not only improves the readability of your code but also helps it be maintained.

Operators, Increments, Decrements, and Variable Declarations

The C language has many operators for performing mathematical calculations. These operators allow you to perform various arithmetic operations at each stage of program execution. The main operators used for mathematical calculations in C are listed below.

  • + — plus;
  • — — minus;
  • * — multiplication;
  • / — division;
  • % — gives the remainder when dividing one number by another.

The C programming language includes variables that have already been discussed earlier. In addition, C can contain syntactic sugar — constructs that simplify the writing of complex expressions and make code more readable. Syntactic sugar allows programmers to express their ideas effectively, making code easier to understand and maintain.

When creating variables, they must be declared by specifying the data type and ending the line with a semicolon. Let's consider an example of creating a variable called counter, which will function as a simple counter. This is a similar element that we used in Scratch, although in programming it is presented in a more complex form.

  • int — a pointer to the variable type;
  • counter — the name of the variable;
  • = — an assignment operator for any value (this is not “equal”, but an assignment operator; it does not simply say that some values ​​are equal, it actually assigns the value from the right side to the left side of the expression);
  • 0 — the value that we assign to the variable;
  • ; — an ending for almost any semantic unit in C.

Scratch has a convenient visual block that allows you to create a counter whose value is updated when a certain action is performed, increasing by one. In the C programming language, the following code can be used to increment the counter value:

Note that the equal sign in this context is not an equal sign, but rather an assignment operator. If it truly denoted equality, the expression itself would be meaningless. The operation of increasing a counter by one, also known as increment, is one of the most common in programming. In this example, we will demonstrate how syntactic sugar works. Pay attention to the details.

This means that the value of the counter variable is increased by one. There is a simpler way to achieve the same result.

Operations similar to increment can be performed with the decrement operator — . This operation, called decrement, allows you to decrease the value of a variable by one.

When changing the value of an existing variable in programming, there is no need to re-specify its type. This means that once a variable has been declared with a certain data type, further changes to its value can occur without specifying the type. This approach simplifies the process of working with variables and makes the code more compact and readable. This is especially convenient in dynamically typed languages, where the type of a variable can change depending on the value assigned.

Why do we need the main function?

The line int main(void) is the starting point of a C program. It denotes the main function, which is required for every program written in this language. It is important to understand that this is the line from which the code execution process begins. The main function can take arguments, but in this case, void is used, which means there are no parameters.

The main function returns an integer value that indicates the success or failure of the program. The value 0 usually indicates success, while any other value may indicate errors. Thus, the line int main(void) not only denotes the starting point of the program, but also defines the structure necessary for the correct completion of the code execution. Understanding this line is important for developing and debugging C programs.

A standard C program begins with the declaration of the function int main(void). This line informs the compiler of the presence of a main function named main, which returns an integer of type int. The keyword void indicates that the function has no arguments, which translates as "emptiness." The main function is the entry point for program execution and plays an important role in its structure. A proper understanding of this element is fundamental to developing C programs.

Curly braces, which mark the beginning { and end } of a function body, play an important role in code structure. They are used not only in functions, but also in other programming building blocks. These braces always indicate the beginning and end of a specific entity in the code, making them key to the proper organization and reading of programs. Proper use of curly braces helps you better understand your program logic and simplifies the debugging process.

When the program reaches the end of the main function, indicated by the closing curly brace, it automatically returns 0. This is because our function type is int, which indicates an integer result. The return value is key because the operating system uses it to determine the program's exit status. A value of 0 signals that the program completed successfully.

Header Files

Let's dive deeper into understanding header files. I didn't really pay much attention to them when I was learning Scratch, as we simply used a green flag to run the program and printed the text "hello, world". This approach was simple and straightforward, but header files play an important role in programming. They contain declarations of functions and variables, which allows you to organize your code more efficiently and conveniently. Understanding their purpose and structure will help you create more complex and functional programs.

In the C language, you can’t simply declare a main() function with a nested printf() function. A preliminary #include statement is required, which tells the compiler to load the code library developed earlier. This allows the compiler to understand what printf() is and how to work with it. Using the standard input/output library is an important part of C programming.

To work with functions such as get_string() and get_int(), you need to load the CS50 library. Without this line, the compiler will not be able to recognize what get_string() is. Files with the .h extension, such as stdio.h and cs50.h, are called header files in the C and C++ programming language. It is important to note that these files contain function declarations, allowing the compiler to interpret and use them correctly. You can think of them as a restaurant menu, where instead of dishes, all the available functions are listed. This "menu" simplifies the programming process by providing access to the necessary tools and methods.

The library provides all the functions we discussed earlier, while the header file serves as a special mechanism for including the necessary functions in your code. For example, the library might be called CS50 or Standard I/O, and the corresponding header files would be named stdio.h and cs50.h. Proper use of header files allows you to optimize your code and improve its readability by providing access to the necessary functions without redundancy.

Linux Commands

Now let's open the Explorer tab of the IDE and examine the structure of our software project. The screenshot shows that the project contains two files: hello and hello.c. These files are the main components we will use to develop and compile our program.

Command line in VS Code Screenshot: CS50 / YouTube

Imagine that You need to organize code for classes for students in different groups or with different C-language programs. In the graphical interface, we can easily accomplish this task using familiar icons from macOS, Windows, or Linux operating systems. Using these icons, you can create a new directory and name it as you wish. This will allow you to manage projects more efficiently and make it easier to access training materials.

This article provides a detailed guide to the Linux command line. We cover the basic commands and their uses, which will help you work effectively in the Linux environment. Learn about terminal functionality, file and directory management, and system settings. Our guide is intended for both beginners and experienced professionals looking to deepen their knowledge. Get useful tips and tricks for optimizing your work with the Linux command line.

Working with the file system can be done efficiently through the command line. For example, by entering the ls command in the command interface, you can view the contents of a project. In this list, names with a slash (/) at the end indicate folders, not regular files. To create a new directory, use the mkdir command, which stands for Make DIRectory. This allows you to quickly organize files and simplify project navigation.

Using the command line in VS Code Screenshot: CS50 / YouTube

The clean command in command mode is designed to delete the history of commands entered in the command line. This action helps clear the list of previous commands, allowing you to focus only on the most recently entered queries. Although I don't often use this command in practice, I use clean as part of the teaching process to provide a more streamlined experience and minimize the amount of unnecessary information.

The mkdir command is used to create a new directory in the file system. After entering this command, you must specify a name for the new directory. For example, the command mkdir pset1 will create a directory intended for storing the first week's code, while the command mkdir pset2 will create a similar directory for the second week's code. Using mkdir helps organize files and projects, making them easier to manage and access.

Now I'm going to change to one of the newly created directories. To do this, I'll enter the command cd pset1 in the command line. The cd command stands for Change Directory, which translates as "change directory." After typing this command and pressing Enter, two important things happen: the command prompt changes to the name of the directory I just changed to, which helps me remember my current location in the file system. This is a convenient navigation method that makes working at the command line more efficient and organized.

Once this operation is complete, you can use the ls command to list the contents of the directory. Typing this command will list the files in the current directory. In this case, since the folder is still empty, the result will be no files.

Let's create a new file in the folder using the command code my_first_program.c. This file will appear in a new tab in your editor. To move up one level in the file system, use the cd .. command, which will take you to the parent directory. If you need to move up two levels, type cd ../.. . The ./ symbol represents the current directory. The command line has functionality similar to the GUI, but in a more comprehensive way. It should be noted that these commands are terminal-specific and are not part of the C language. Using the command line can greatly simplify working with files and directories, speeding up the development process.

C++ Developer from Scratch Profession

C++ programmers create complex programs and services. They develop high-load network applications, games, graphics engines, and components for operating systems and hardware. Windows, Linux, macOS, Android, Chrome, Counter-Strike, StarCraft, and Diablo are written in this language. You will master this legendary programming language from scratch: you will write a search engine and gain teamwork skills.

Learn more