Advertisement
CybEl

HeapAndStack

Sep 15th, 2020
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. #include <iostream>
  2. //Configuration Properties >> C / C++ >> Preporocessor >> Preprocessor Definitions >> _CRT_SECURE_NO_WARNINGS
  3.  
  4.  
  5. int main()
  6. {
  7. char buff[10] = {0}; //Stored on stack, variables get memory allocated on the stack when they are called
  8. strcpy(buff, "This String Will Overflow the Buffer");
  9.  
  10. //Heap example
  11. int* ptr = new int[10];
  12. //Needs to have memory alocated and de-allocated by program code. If it is not handled well it will lead to memory leaks.
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement