From the course: C Programming for Embedded Applications
Unlock the full course today
Join today to access over 24,700 courses taught by industry experts.
The const qualifier - C Tutorial
From the course: C Programming for Embedded Applications
The const qualifier
- [Instructor] When defining constants, you may have used either of the methods shown in this example. Both define a constant for the digital pin where some LED is to be connected. This is an Arduino example, so pin 13 is a valid option. The first one uses the const qualifier in a variable definition. Although defining a constant variable sounds like a contradiction, the language never called it a variable, I did. The second option is using the help of the pre-processor with the #define directive. This type of constant is called a macro. The main difference between these options is that the so-called constant variables are usually stored in read only memory. Macros are always stored in ROM because they are inlined. So they are part of the code. That means they are copied as constants in the code each time they are used. So what does the const qualifier do? The const qualifier means that a variable will not be changed…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.