+ 2
Can this code really kill the memory?
#include <iostream.h> void main() { char a=0; char *ptr=&a; while (1) { *ptr =0; ptr++; } }
2 Réponses
+ 8
If there were no protections by the OS, yes. In reality however every modern OS stops programs that access memory that doesn't belong to them. Linux does this very strictly, Windows is a bit more tolerant but overall you can't really abuse pointers in that way.
- 1
Let me see if I understand, you are creating an infinite loop?