In a program that manipulates text, you need to store multiple strings. What is a potential issue with using character arrays instead of string literals?

  • Character arrays are less efficient in terms of memory usage compared to string literals.
  • Character arrays can't accommodate variable-length strings, making it challenging to store strings of different sizes.
  • Character arrays may lead to null-termination errors if not handled carefully.
  • Memory management becomes complex with character arrays, as you need to manually handle memory allocation and deallocation.
Using character arrays for storing multiple strings in a text-manipulation program can be problematic because character arrays have a fixed size and don't easily adapt to variable-length strings. This can lead to memory wastage or buffer overflows. String literals, on the other hand, are more flexible.
Add your answer
Loading...

Leave a comment

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