Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6
Strings and arrays are quite similar except the length of an array is fixed whereas strings can have a variable number of elements. Technically, arrays are a special type of variable that can hold more than one value at a time. They are a sequential collection of elements of similar data types, whereas strings are a sequence of characters used to represent text rather than numbers. In addition, strings are immutable which means the value of an object cannot be modified once it’s created, while arrays are mutable meaning the fields can be modified. Simply put, an array is a collection of like-type variables whereas a string is a sequence of characters represented by a single data type.
23rd Apr 2019, 7:52 PM
Md Habibur Rahman
Md Habibur Rahman - avatar
+ 12
A character array is just a character array, while a string is a class which contains a character array, and has built-in methods to help you manage that character array. You may choose to allocate memory for a character array on the stack or the heap, while strings are automatically managed for you. https://stackoverflow.com/questions/1287306/difference-between-string-and-char-types-in-c
21st Apr 2019, 8:30 PM
♥️Best Couple♥️
♥️Best Couple♥️ - avatar
+ 7
Here in 2019 Strings can also be objects, and coded in memory in a few different ways. The main difference is how they are supposed to be used. Stings are meant to store text, like tweets, or passages in a book, or comments, . For a deep dive, you might look up the topics: EBCDIC, ASCII, and UTF-8. Strings have expanded in capability over the years as support for more languages, math, and technical symbols. 64 bit memory devices, can store a ridiculous amount of codes in one memory location, and each code can represent a character. What character? That is really up to the engineers, but they decide these issues at intertnational conventions.
21st Apr 2019, 3:09 AM
James McLain
James McLain - avatar
+ 6
String is data, Array is datastructure.
21st Apr 2019, 12:13 PM
Daniel Adam
Daniel Adam - avatar
+ 5
Depends on the language, too. In C, a string is an array of chars that ends with '\0' (the signal sign to stop reading). And if that termination symbol is missing, it's just a char array.
20th Apr 2019, 12:31 PM
HonFu
HonFu - avatar
+ 5
This is sometimes language dependent.
22nd Apr 2019, 4:44 AM
Sonic
Sonic - avatar
+ 4
array = [3, "s", true, "hello"] string = "Hello its just a String..." print(array[2]) #true print(array[1]) # s print(array) #[3, "s",...] print(string[1]) # e print(string) #Hello its just a string
21st Apr 2019, 2:55 PM
I‘m Sarah🌹
I‘m Sarah🌹 - avatar
+ 4
Of course you can have an array of strings, or even a two dimensional array of strings.
22nd Apr 2019, 6:21 AM
James McLain
James McLain - avatar
+ 3
I am learning a lot from reading the discussion on here.
21st Apr 2019, 11:20 PM
Jordan McGrath
Jordan McGrath - avatar
+ 2
Strings are similar to arrays with just a few differences. Usually, the array size is fixed, while strings can have a variable number of elements. Arrayscan contain any data type (char short int even other arrays) while strings are usually ASCII characters terminatedwith a NULL (0) character.
20th Apr 2019, 12:40 PM
Er. Mohd. Shadab
Er. Mohd. Shadab - avatar
+ 2
A string can be considered as a variable or value whereas an array contains many values. A string does not have a fixed length but an array can be any data type with a fixed length. Usually in coding, strings are indicated by apostrophe symbol("string") while array does not have apostrophe
22nd Apr 2019, 12:27 AM
Egunjobi Ayooluwa
Egunjobi Ayooluwa - avatar
+ 2
To declare an array you must know the data type of the items that you are going to put into the array. Each item must be of the same type. Then pick a nice descriptive name for your array, and decide how many items it will need to store, at MOST....
23rd Apr 2019, 12:14 PM
James McLain
James McLain - avatar
+ 2
Let's say that you want to store a season's worth of baseball scores for the favorite team, the Peeps. You know that they will play 24 games. You know that scores never have a fractional part. So, an integer data type is the best for this array. You chose the name: peep2019scores. With all of this ready you would declare you array like this:. int[] peep2019scores = new int[24];. The square brackets are the critical part that makes this an array and not just a single integer variable.
23rd Apr 2019, 12:24 PM
James McLain
James McLain - avatar
+ 1
Recently I learn c++ so I have no much more idea about its features and I really want to know what is the difference between string array, I also tried to declare array but it shows an error dell error code 2000-0333, so I really want a solution how to declare an array in c++.
23rd Apr 2019, 11:34 AM
liza
+ 1
Recently I learn c++ so I have no much more idea about its features and I really want to know what is the difference between string array, I also tried to declare array but it shows an error https://errorcode0x.com/solved-dell-error-code-2000-0333/, so I really want a solution how to declare an array in c++.
23rd Apr 2019, 11:35 AM
liza
+ 1
A string contains characters while arrays can contain different data types and more number of data types.
23rd Apr 2019, 7:09 PM
Victor Peter Ukok
Victor Peter Ukok - avatar
0
Bhai dekh string is a collection of words and array is a data of similar type which are calling by common name
23rd Apr 2019, 1:20 PM
DEEPAK KUMAR
DEEPAK KUMAR - avatar