Q009

Untitled

Mar 12th, 2014
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. //////////////
  2. // main.cpp //
  3. //////////////
  4.  
  5. #include <stdio.h>
  6.  
  7. int newFoo(int i);
  8. void printFooNum();
  9.  
  10. static int foos[] =
  11. {
  12. newFoo(1),
  13. newFoo(2),
  14. newFoo(3),
  15. newFoo(4)
  16. };
  17.  
  18. int main()
  19. {
  20. printFooNum();
  21. printf("\n\nThe program has ended..\n"); fflush(stdin); getchar();
  22. return 0;
  23. }
  24.  
  25. /////////////////////
  26. // anotherFile.cpp //
  27. /////////////////////
  28.  
  29. #include <stdlib.h>
  30.  
  31. std::vector<int> foo;
  32.  
  33. int newFoo(int i)
  34. {
  35. foo.push_back(i);
  36. printf("Adding foo [addr: 0x%X]. New size: %d\n", &foo, foo.size());
  37. return i;
  38. }
  39.  
  40. void printFooNum() { printf("foo [addr: 0x%X] size: %d\n", &foo, foo.size()); }
Advertisement
Add Comment
Please, Sign In to add comment