Categories:
.NET (357)
C (330)
C++ (183)
CSS (84)
DBA (2)
General (7)
HTML (4)
Java (574)
JavaScript (106)
JSP (66)
Oracle (114)
Perl (46)
Perl (1)
PHP (1)
PL/SQL (1)
RSS (51)
Software QA (13)
SQL Server (1)
Windows (1)
XHTML (173)
Other Resources:
Strings vs. Character Arrays
What is the difference between strings and character arrays?
✍: FYIcenter
A major difference is: string will have static storage duration, whereas as a character array will not, unless it is explicity specified by using the static keyword.
Actually, a string is a character array with following properties:
* the multibyte character sequence, to which we generally call string, is used to initialize an array of static storage duration. The size of this array is just sufficient to contain these characters plus the terminating NUL character.
* it not specified what happens if this array, i.e., string, is modified.
* Two strings of same value[1] may share same memory area. For example, in the following declarations:
char *s1 = "Calvin and Hobbes"; char *s2 = "Calvin and Hobbes";
The strings pointed by s1 and s2 may reside in the same memory location. But, it is not true for the following:
char ca1[] = "Calvin and Hobbes"; char ca2[] = "Calvin and Hobbes";
[1] The value of a string is the sequence of the values of the contained characters, in order.
2007-02-26, 6343👍, 0💬
Popular Posts:
What's difference between HashTable and ArrayList ? You can access array using INDEX value of array,...
Write down the equivalent pointer expression for referring the same element a[i][j][k][l]? a[i] == *...
How can method defined in multiple base classes with same name be invoked from derived class simulta...
How To Enter Binary Numbers in SQL Statements? - MySQL FAQs - Introduction to SQL Basics If you want...
If we have the following in a Java code: String s="abc"; String s2="abc"; Then what will be output o...