Câu hỏi phỏng vấn Strings
Câu hỏi

What is a null-terminated String?

Câu trả lời

What is a null-terminated String?

A null-terminated string is a sequence of characters followed by a null character (ASCII value 0 or '\0'). The null character serves as a terminator, indicating the end of the string. This type of string representation is commonly used in programming languages like C and C++.

Here are the key points about null-terminated strings:

Representation

  • A null-terminated string consists of a sequence of characters followed by a null character ('\0').
  • The null character is not part of the string itself but rather a terminator.
  • The length of the string can be determined by finding the position of the null character.

Memory Layout

  • In memory, a null-terminated string is stored as a contiguous block of characters, with the null character at the end.
  • The size of the memory block is typically one byte more than the length of the stri...
junior

junior

Gợi ý câu hỏi phỏng vấn

junior

What is strings mutability and immutability?

senior

What are some advantages of Rope data structure?

expert

When is Rabin-Karp more effective than KMP or Boyer-Moore?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào