How are Strings represented in memory in C?

How are Strings represented in memory in C?

a) As an array of characters
b) As a linked list
c) As a single character
d) As a floating-point number

Answer:

a) As an array of characters

Explanation:

In C, strings are represented in memory as an array of characters terminated by a null character ('\0'). Each character in the string occupies one byte of memory, and the null character marks the end of the string. This null-terminated array allows C functions to determine where the string ends, enabling operations like copying, concatenation, and comparison.

Understanding how strings are represented in memory is essential for handling string manipulation effectively and avoiding errors like buffer overflows.

Reference links:

https://www.rameshfadatare.com/learn-c-programming/

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top