answersLogoWhite

0

How strings and characters are represented in an array?

Updated: 8/19/2019
User Avatar

Wiki User

8y ago

Best Answer

An array of characters is an array of character codes (such as ASCII codes). A string is typically a null-terminated array of characters however some languages use the first array element to specify the string's length.

User Avatar

Wiki User

8y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How strings and characters are represented in an array?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

How are string stored in c language?

Strings represented by the language character set (e.g., ASCII) are stored as null-terminated arrays of type char. Wide-character strings are stored as null-terminated arrays of type wchar_t. Other types are also available, such as char16 and char32 (for UTF16 and UTF32 encodings, respectively).


What are strings in C?

an array of characters, usually terminated by a binary zero (0x00 or \0, not '0')


Write javascript code to display a list of strings?

You need to put the strings in an array, and then loop through the array to output the strings. Something like this would be a simple example: ---------------- var strings = ["s1","s2","s3"]; for ( var i in strings ) { document.write( strings[i] ); }


What is the array of string in c?

A string in C is stored in a 1 dimension array so an array of strings is simply a two dimension array.


Why is c string defined as an array?

Every programming language treats strings as arrays. A C string is defined as being a null-terminated array of characters. A C string that does not have a null-terminator is just an array of character values, but without a null-terminator the onus is upon the programmer to keep track of the array's length.


What is the difference between numeric array and associative array?

Numeric array has numbers(+integers) that represent the values Associative array has strings that represent the values


Where string arrays belong in a C program?

There is no data type string in C. String is handled as an array of characters. To identify the end of the string, a null character is put. This is called a null terminated character array. So array of strings will be a double dimensioned array of chars. It is implemented as an array of pointers, each pointer pointing to an array of chars.


What is return type of string in c?

In C programming, a string doesn't have a specific return type as it's essentially an array of characters. So, if a function is returning a string, it should be declared to return a pointer to a char (char*), since a string in C is represented as an array of characters terminated by a null character ('\0').


How can a list of strings be stored within a two dimensional array?

Think of the strings as writing on lines of paper. Paper is a two dimensional surface. The computer array is the equivalent of the two dimensional paper.


What is the difference between a string and an array?

Nothing whatsoever. A string is simply an array of type char. In some programming languages, such as C, a string is an array of char (or short), terminated with a null \0. An array is just a fixed size of collection, a container to hold things/objects. If all the elements in the container are characters (of char), then we may call it a string, sometimes a byte array (because each character can be represented as a byte). An array of 7 different days, it maybe a WEEK, or just the birthdays of 7 dwarfs. Then they are nothing to do with strings. A data item (or variable) is described as a "string" type when it contains some number of characters. Those characters can usually be anything in the system's accepted list of codes. Most systems use ASCII, so a string can include the letters a-z, A-Z, numbers 0-9, and special characters like ~!@#$%^&*()_+-=[]\{}|:";'<>?,/. A string is treated as a single object, although most programming languages have methods to break strings apart (called sub-stringing). In the Perl language, strings are named $something. An array is a collection of individual data items, sort of like a list. Each element in an array can be referred to in a program by its position in the list. In the Perl language, an array would be named @SOMETHING. The first element in the array would be named $SOMETHING[0], the second $SOMETHING[1], and so on. Each element can be a string, or some other data type. Other data types would be integers (positive or negative whole numbers), floating point (decimal numbers like 3.14159 or 2398.41; it can be more complicated than this, but that's another story), and a few more exotic types. In the C programming language a string is actually the same as an array of characters. The last character in a C string is a zero byte which indicates the end of the string.


What elements are in string?

A string is an array of characters.


What character terminates all character array strings?

the character string is terminated by '\0'