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:
Why doesnt strcat work? ....
Why doesn't
strcat(string, '!');
work?
✍: Guest
There is a very real difference between characters and strings, and strcat concatenates strings.
A character constant like '!' represents a single character. A string literal between double quotes usually represents multiple characters. A string literal like "!" seems to represent a single character, but it actually contains two: the ! you requested, and the \0 which terminates all strings in C.
Characters in C are represented by small integers corresponding to their character set values Strings are represented by arrays of characters; you usually manipulate a pointer to the first character of the array. It is never correct to use one when the other is expected. To append a ! to a string, use
strcat(string, "!");
2016-03-14, 1764👍, 0💬
Popular Posts:
How Many Tags Are Defined in HTML 4.01? There are 77 tags defined in HTML 4.01: a abbr acronym addre...
How To Create an Array in PL/SQL? - Oracle DBA FAQ - Introduction to PL/SQL If you want create an ar...
How To Set session.gc_divisor Properly? - PHP Script Tips - Understanding and Using Sessions As you ...
Can JavaScript steal text from your clipboard? It is true, text you last copied for pasting (copy &a...
.NET INTERVIEW QUESTIONS - Did VB6 support multi-threading ? While VB6 supports multiple single-thre...