Of pointers - seg faults, memory leaks and assorted troubles
As I understand it, this code would lead to a segfault in Linux and probably unexpected behaviour in OSes where there is no concept of "protected memory". Am I right?
Code:
char *str; /* Don't initialize the pointer - it is initialized to some random memory location */ Code:
void func1 () Or a classic memory leak scenario: Code:
int* array = new int[100]; |
Ask your instructor?
|
DECLARATION:
I don't have one (an instructor). I'm not asking for homework help. I left school about 8 years ago. I'm a hobbyist programmer. I love dabbling with C/C++. I'm not a school kid. I'm doing my MBA now. I just want to discuss pointers and their intricacies in different compilers with fellow C/C++ programmers out of academic curiosity. /END DECLARATION |
You have missed the obvious one.
Code:
void func() |
All times are GMT -5. The time now is 11:27 AM. |