- The input string is not null-terminated.
- Causes buffer overflow vulnerabilities.
- Can only read a predetermined number of characters.
Explanation:
Option c is the correct answer. It can cause buffer overflow because the gets method will not check the limits of the input buffer.
- Which of the following options describes the functions of the setjmp and longjmp functions in C?
- Longjmp sets its destination with setjmp and creates a non-local goto.
- Longjmp sets the destination, and setjmp is a non-local goto.
- Non-local goto are generated by both setjmp and longjmp.
- Longjmp is a local goto, and setjmp sets a local jump.
Explanation:
Option A is the correct answer. Setjmp saves the current state so that longjmp can use it later, which is a non-local goto in the protected environment.
- Regarding structural padding in C, which of the following is true?
- Structural padding is used to conserve memory.
- Structure padding guarantees that parts of the structure fit well in memory.
- Only the array is affected by structural padding.
- Structural padding is used to ensure that structures are the same size.
Explanation:
Option b is the correct answer. Structural padding is used to ensure that the members of a structure align according to the alignment specifications of the platform.
- Which of the following actions in C are negated?
- Adding a pointer with an integer.
- Deducting a number from a reference.
- Analyzing two arrows.
- Incrementing an integer with a pointer.
Explanation:
Option d is the correct answer. You can't increment an integer with a pointer. Multiplication doesn't work properly on pointers, but you can add, subtract, and compare integers.
- What does it mean when the extend keyword is used for variable declaration in C programming?
- It means that the variable is defined globally in another file.
- The variable is a globally accessible local variable.
- Variables are allocated dynamically at runtime.
- For quick access, the variable is kept in a register
Explanation:
Option A is the accurate choice. The extern keyword is employed to signify a global variable that has been declared in a different file, enabling multiple files to utilize the same variable.
The outcome of the sizeof(char) expression in C varies based on the system in use.
Explanation:
Option b is the correct answer. The C standard states that a character can be only 1 byte, independent of the order.
- Which of the following option represent a segmentation failure in C?
- Error resulting from a division of zero.
- An error caused by a syntax error in the program.
- Error resulting from an infinite loop.
- An error is raised when a program tries to access the memory which is not authorized.
Explanation:
Option d is the correct answer. Segmentation error occurs when a program tries to access memory for which it does not have access; it is usually occurs due to an invalid pointer specified.
- Which of the following refers to the use of assert.h in C?
- It provides ways to allocate memory dynamically.
- Provides a means to terminate the program if a condition is not met.
- It has functions to perform calculations in mathematics.
- Provides features for managing file input/output systems.
Explanation:
Option b is the correct answer. Typically, the macro asserts in assert.h is used for debugging. If any condition fails in the c program, assert.h can be used to terminate the program.
- What is the main function of C's inline keyword?
- To recommend that the function be optimized by the compiler to run more quickly.
- To recommend that the function be expanded inline at the place of call by the compiler.
- To enable access to the function from other translation units.
- To make the function's implementation in assembly language mandatory.
Explanation:
Option b is the correct answer. The inline keyword tells the compiler to extend the inline function instead of calling the standard function.
- What is the use of C #define directive?
- Macros are defined for functions or constants.
- Includes program standard libraries.
- The memory is allocated dynamically.
- If a condition becomes false, it closes the program.
Explanation:
Option A is the accurate choice. Developers have the ability to employ meaningful titles for constants or functions instead of fixed values through the generation of macro definitions for them utilizing the #define command.