Strings in c are actually one-dimensional arrays of characters?
Question: Strings in c are actually one-dimensional arrays of characters?
Yes, strings in C programming language are actually one-dimensional arrays of characters. Each character in the string is stored in a consecutive memory location, and a null character '\0' is automatically appended at the end of the string to indicate the end of the string.
For example, the string "hello" is represented as an array of characters in memory as follows: {'h', 'e', 'l', 'l', 'o', '\0'}. This allows various string manipulation functions to work with strings as arrays of characters, and also enables C programmers to manipulate strings using pointer arithmetic.
0 Komentar
Post a Comment