Tasks studies - laboratory
Project maintained by dawidolko Hosted on GitHub Pages — Theme by dawidolko
Lab 00 - Environment Configuration
Questions
-
Find and list the versions of the C language standard.
-
What is a compiler?
-
Describe what an IDE (Integrated Development Environment) is. How does it facilitate the programmer’s work?
-
List the conventions for naming variables in programming and provide examples.
Tasks (description for Windows systems):
- Install Visual Studio Code
- Install a C language compiler. For example, the MinGW package containing the GCC compiler for Windows.
:warning: Pay attention to the location of the package installation. You will need it for the next steps.

- During installation, in one of the steps, select the packages you want to install. (all)

- After selecting the packages, click installation > Apply Changes and confirm your selection.

- To access the GCC tool from the cmd or powershell terminal, the path to the file must be in the system variables. Check if the command is available by typing
gccin the terminal. If the following message appears in the terminal, skip the next step.
- If the gcc command is not available, find the option “edit the system enviroment variables” in the start menu or “edit environment variables” in the Polish version of the system.

- In the next window, select “Environment Variables” or “Environment Variables” (the button should be in the same place regardless of the Windows version)

- Find the Path variable and press edit.

- In the edit window, click New and then Browse and find the location of the gcc.exe file (bin folder in the folder where MinGW was installed). For example, if MinGW was installed in C:\Applications\MinGW the Path entry should look like this

- Confirm by pressing ok and test the gcc command again in the CMD or PowerShell terminal. The following message should appear

-
Create a folder with your initials and album number on the desktop and in it the lab1 folder. Start Visual Studio Code and then open the created lab1 folder.
- Create the file myfirstapp.c (source files of applications that require compilation have the suffix .c [1] [2])
- In the created file write your first program that prints
Hello World!and the version of the C language standard used for compilation.
- Save the file, start the terminal, and then compile the program with the command
gcc path_to_program –o executable_name[1] - Run the compiled program by typing its name in the terminal. Run the program in the second way by double-clicking the file.
- Visual Studio Code is a tool that we can configure according to our needs thanks to plugins. Install the C/C++ Extension Pack. One of its functionalities is syntax highlighting.

-
The CodeRunner add-on will allow you to compile the active file and then run the generated program.
- Compile and run the program using the Visual Studio Code IDE thanks to the installed plugins. With the tab with your program selected, find the following option:

- Modify the program by “commenting out” the stdlib.h library declaration (lines starting with the characters “//” are comments that do not affect the code’s operation. The compiler ignores them).

- Run the program and find the place where the error occurring in the program is described.
CodeRunner configuration
By default, the code runner plugin starts the program in read mode. This means that it will not be possible to read data from the keyboard. To get this option, in the VSCode settings, you need to find the following option:

To modify the command compiling the C code, find the option:
and then edit the settings.json file. For example, to force the code to be compiled to the c99 standard, the command should be modified as follows:

To specify the correct path to the compiler, find the following settings panel:

Then provide the path to the installed compiler:

After you have finished working:
- Save your results
- Delete the created files from the desktop