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:
malloc is returning crazy pointer values ...
malloc is returning crazy pointer values, I have included the line
extern void *malloc();
before I call it.
✍: Guest
malloc accepts an argument of type size_t, and size_t may be defined as unsigned long. If you are passing ints (or even unsigned ints), malloc may be receiving garbage (or similarly if you are passing a long but size_t is int).
In general, it is much, much safer to declare standard library functions by #including the appropriate header files, rather than typing extern declarations yourself. (A related problem is that it is not safe to print size_t values, including the result of sizeof, using printf's %d format. The portable approach is to use an explicit (unsigned long) cast, and %lu format: printf("%lu\n", (unsigned long)sizeof(int)).
2016-04-15, 1789👍, 0💬
Popular Posts:
What is the difference between RegisterClientScriptBloc kand RegisterStartupScript? RegisterClientSc...
What will be printed as the result of the operation below: main() { int x=10, y=15; x = x++; y = ++y...
How do we create DCOM object in VB6? Using the CreateObject method you can create a DCOM object. You...
How To Compile a JUnit Test Class? Compiling a JUnit test class is like compiling any other Java cla...
What is effort variance? Effort Variance = (Actual effort – Estimated Effort) / Estimated Effort.