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 does this code crash?
Why does this code:
char *p = "hello, world!";
p[0] = 'H';
crash?
✍: Guest
String constants are in fact constant. The compiler may place them in nonwritable storage, and it is therefore not safe to modify them. When you need writable strings, you must allocate writable memory for them, either by declaring an array, or by calling malloc. Try
char a[] = "hello, world!";
By the same argument, a typical invocation of the old Unix mktemp routine
char *tmpfile = mktemp("/tmp/tmpXXXXXX");
is nonportable; the proper usage is
char tmpfile[] = "/tmp/tmpXXXXXX";
mktemp(tmpfile);
2015-05-27, 1211👍, 0💬
Popular Posts:
I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, ...
.NET INTERVIEW QUESTIONS - What are Daemon threads and how can a thread be created as Daemon? Daemon...
How To Return the Second 5 Rows? - MySQL FAQs - SQL SELECT Statements with JOIN and Subqueries If yo...
What is test metrics? Test metrics accomplish in analyzing the current level of maturity in testing ...
What Is a TD Tag/Element? - XHTML 1.0 Tutorials - Understanding Tables and Table Cells A "td" elemen...