Categories:
.NET (961)
C (387)
C++ (185)
CSS (84)
DBA (8)
General (31)
HTML (48)
Java (641)
JavaScript (220)
JSP (109)
JUnit (31)
MySQL (297)
Networking (10)
Oracle (562)
Perl (48)
Perl (9)
PHP (259)
PL/SQL (140)
RSS (51)
Software QA (28)
SQL Server (5)
Struts (20)
Unix (2)
Windows (3)
XHTML (199)
XML (59)
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, 6220👍, 0💬
Popular Posts:
How To Run "mysql" Commands from a Batch File? - MySQL FAQs - Command-Line End User Interface mysql ...
Can Multiple Cursors Being Opened at the Same Time? - Oracle DBA FAQ - Working with Cursors in PL/SQ...
How can we implement singleton pattern in .NET? Singleton pattern mainly focuses on having one and o...
Can we get a strongly typed resource class rather than using resource manager? In the previous quest...
How To Dump the Contents of a Directory into an Array? - PHP Script Tips - Working with Directoris a...