Recall & Review
beginner
What is a predefined macro in C?
A predefined macro is a special identifier that the C compiler automatically defines before compilation. It provides useful information like the current file name, line number, or compilation date.
Click to reveal answer
beginner
What does the predefined macro
__FILE__ represent?The
__FILE__ macro expands to the name of the current source file as a string literal.Click to reveal answer
beginner
What value does the predefined macro
__LINE__ hold?The
__LINE__ macro expands to the current line number in the source file as an integer constant.Click to reveal answer
intermediate
What information does the predefined macro
__DATE__ provide?The
__DATE__ macro expands to a string literal representing the date when the source file was compiled, in the format "Mmm dd yyyy".Click to reveal answer
intermediate
How can predefined macros help in debugging C programs?
Predefined macros like
__FILE__ and __LINE__ can be used to print the current file name and line number, helping programmers quickly find where an error or message originated.Click to reveal answer
Which predefined macro gives the current line number in a C source file?
✗ Incorrect
The macro __LINE__ expands to the current line number in the source file.
What does the predefined macro __FILE__ return?
✗ Incorrect
The macro __FILE__ expands to the name of the current source file as a string.
Which predefined macro provides the date when the program was compiled?
✗ Incorrect
The macro __DATE__ expands to the compilation date as a string.
How can predefined macros be useful in debugging?
✗ Incorrect
Predefined macros like __FILE__ and __LINE__ help identify where in the code an error or message occurs.
Which of these is NOT a standard predefined macro in C?
✗ Incorrect
__COMPILER__ is not a standard predefined macro in C.
Explain what predefined macros are in C and list at least three common examples with their purpose.
Think about what information the compiler automatically provides during compilation.
You got /4 concepts.
Describe how you can use predefined macros to help find bugs in your C program.
Consider how knowing the exact file and line number can speed up fixing problems.
You got /3 concepts.