0

I am learning VC++. I am wondering why i can't see full value {99,20,14,80} in "printElements3". I could see only "arr" 0xmemory address and following by "99", the first value. Does this mean I have to pass by Reference in order to see the full array values?

Appreciate someone can help me understand this. below is my code.

 #include <iostream>

 void printElements3(int *arr, int size)
 {

  for (int i= 0 ; i < size; ++i)
  {
    std::cout << arr[i] << std::endl;
  }
 }

  int main()
  {
     int arr[4]={ 99, 20, 14, 80 };
     printElements3(arr,4);
     return 0;
  }
user10293779
  • 103
  • 6
  • 1
    [Works for me](http://coliru.stacked-crooked.com/a/7920acdeb0ca80af) – tkausl Sep 01 '18 at 13:43
  • [Works fine here as well.](http://cpp.sh/7zxzw) [And here.](https://onlinegdb.com/SyRVy7OwQ) Are you sure this is the code you are actually compiling and running? – Max Vollmer Sep 01 '18 at 14:17
  • 2
    I believe OP is talking about viewing in the debugger, not the program output. [How to display a dynamically allocated array in the Visual Studio debugger?](https://stackoverflow.com/questions/75180/how-to-display-a-dynamically-allocated-array-in-the-visual-studio-debugger) – Raymond Chen Sep 01 '18 at 14:28
  • 1
    As an aside, from what I can see you aren't trying to learn VC++ (which I guess means the Microsoft dialect of C++), but standard C++. Anyway, consider learning a newer version, preferably the current one. – Deduplicator Sep 01 '18 at 15:13

0 Answers0