search
Login

Categories


C Books Guide and List
C++ Books Guide and List
Best Java Books

3.8k questions

4k answers

117 comments

10.7k users

0 votes
44 views
asked Expert 15k points 15 23 30

1 Answer

0 votes
An array is an array of anything. A string is a specific kind of an array with a well-known convention to determine its length.
There are two kinds of programming languages: those in which a string is just an array of characters, and those in which it’s a special type. In C, a string is just an array of characters (type char), with one wrinkle: a C string always ends with a NUL character.
The “value” of an array is the same as the address of (or a pointer to) the first element; so, frequently, a C string and a pointer to char are used to mean the same thing.
An array can be any length. If it’s passed to a function, there’s no way the function can tell how long the array is supposed to be, unless some convention is used. The convention for strings is NUL termination; the last character is an ASCII NUL (‘’) character.
answered Expert 11.4k points 14 22 28

Related questions

0 votes
1 answer 22 views
22 views
asked sunny Expert 11.4k points 14 22 28
0 votes
1 answer 61 views
61 views
What is the best way to write an array to a file in PHP?
asked snag Jr Member 370 points 1 9
0 votes
1 answer 44 views
0 votes
1 answer 57 views
...