What is the difference between Array and String? - ProProfs Discuss
Topics
Products
Follow Us:

What is the difference between Array and String?

Asked by E. Stanley, Last updated: Jan 19, 2020

+ Answer
Request

2 Answers

Larry Thornton

Curious about the World

Larry Thornton, Student, MBA, Los Angles

Answered Nov 28, 2019

Array refers to a special collection of variables that form a part of the same data. The array can hold more than one value at a time. It is faster to access arrays than accessing strings. The last character in the array is usually an element of a special type. It is important to note that the array has a fixed size and number of values.

String, on the other hand, refers to a class of characters represented in a single data type. Unlike an array, the string can hold only char data. The last character of the string is a null character. The size of a string is variable. It can also be stored in any manner in a memory location.

 

P. Halah

P. Halah

Answered Nov 14, 2019

Arrays are a particular variable that refers to a collection of like type variables that are related to by a common name. It is a sequenced collection of elements of the same base types that share a single name. It offers a convenient means of compiling related data together.

A string is a progression of characters that are represented as a single data item that is terminated with a unique character. It is a sequence of values with a universal name. Unlike arrays, strings cannot be altered once they are assigned.

A string class encompasses a pointer to some part of the heap memory, while the actual contents of the string are stored in memory. Also, Strings are stored like other types of arrays when they are proclaimed as being character arrays.

 

Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer
Search for Google images
Select a recommended image
Upload from your computer

Email Sent
We have sent an email to your address "" with instructions to reset your password.