L
LinLMa
Hello everyone,
I find strange result in the following program.
1. For string array, dereferencing it will result in the string
itself, but for int array, dereferencing it will result in the address
of the array;
2. When dereferencing it twice (operator **), why the result is always
the 1st element in both string array sample and int array sample?
thanks in advance,
George
I find strange result in the following program.
1. For string array, dereferencing it will result in the string
itself, but for int array, dereferencing it will result in the address
of the array;
2. When dereferencing it twice (operator **), why the result is always
the 1st element in both string array sample and int array sample?
Code:
#include <iostream>
#include <string>
using namespace std;
int main()
{
wchar_t me[] = L"Hello World \n";
wchar_t (*me2_ptr)[14] = &me;
wcout << *me2_ptr << endl; // output Hello World
wcout << **me2_ptr << endl; // output H
int values[] = { 10, 20, 30, 40, 55, 60, 70, 80, 90, 100 };
int (*pval)[10] = &values;
wcout << *pval << endl; // output 0x0017f6f0
wcout << **pval << endl; // output 10
return 0;
}
thanks in advance,
George