Dev/C, C++

[ C, C++ ] malloc 캐스팅 왜 안 해도 되는지 관련 글 링크

surimi🍥 2021. 10. 18. 18:54
반응형

https://stackoverflow.com/questions/605845/do-i-cast-the-result-of-malloc/605858#605858

 

Do I cast the result of malloc?

In this question, someone suggested in a comment that I should not cast the result of malloc. i.e., I should do this: int *sieve = malloc(sizeof(int) * length); rather than: int *sieve = (int *) m...

stackoverflow.com

 

https://stackoverflow.com/questions/7545365/why-does-this-code-segfault-on-64-bit-architecture-but-work-fine-on-32-bit

 

Why does this code segfault on 64-bit architecture but work fine on 32-bit?

I came across the following C puzzle: Q: Why does the following program segfault on IA-64, but work fine on IA-32? int main() { int* p; p = (int*)malloc(sizeof(int)); *p = 1...

stackoverflow.com

 

반응형