I am trying to get my head around pointers and cant understand why using the dereference operator to print a value works fine when "\n";
is added to the line, but for some reason I dont get any output when I use endl;
. The terminal shows no output with endl;
. Is this something to do with output buffer flushing?
#include <iostream>
using namespace std;
int main()
{
int arrayA[] = {0, 1, 2, 3, 4, 5};
int * ptr_P;
ptr_P = arrayA;
for (int i; i < 6; i++)
{
cout << *ptr_P << "\n"; // Works fine, but endl; does not
ptr_P++;
}
return(0);
}