C ++ prints pointer value

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

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

Somebody knows?

+3
source share
4 answers

If this is really an array of (initialized) double pointers, that is:

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

anything you need:

cout << *arr[i];
+7
source

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

+1
source

cout << *(arr[i]);

+1

"arr"

double* arr[..];

:

cout << *(arr[i])
0

Source: https://habr.com/ru/post/1737869/


All Articles