Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ print value of a pointer

I have an array of double pointers, but every time I try do print one of the values the address gets printed. How do I print the actual value?

cout << arr[i] ? cout << &arr[i] ? they both print the address

Does anyone know?

like image 954
user69514 Avatar asked Mar 21 '10 02:03

user69514


2 Answers

If it's really an array of (initialized) double pointers, i.e.:

double *arr[] = ...
// Initialize individual values

all you need is:

cout << *arr[i];
like image 123
Matthew Flaschen Avatar answered Sep 19 '22 07:09

Matthew Flaschen


cout << *(arr[i]) will print the value.

like image 24
Anatoly Fayngelerin Avatar answered Sep 20 '22 07:09

Anatoly Fayngelerin