What is a string in C?
a) An array of characters terminated by a null character
b) A collection of integer values
c) A pointer to an integer
d) A function that returns a character
Answer:
a) An array of characters terminated by a null character
Explanation:
A string in C is an array of characters terminated by a null character (\0
). The null character marks the end of the string, allowing functions to determine where the string ends. Strings are used in C to represent text, and common operations on strings include concatenation, comparison, and searching for substrings. Because strings are essentially arrays of characters, they can be manipulated using array indexing and pointer arithmetic.
Understanding strings is crucial for handling textual data in C programming, as they are fundamental to input/output operations and text processing.