Archive for October, 2010

[C] Pointor Array size cannot be measured.

Sunday, October 24th, 2010

I learned pointor array.
When I tried to measure size of pointor array, I cannot do.


#include 
using namespace std;

int main (int argc, char * const argv[]) {
	int *a;
	int b[] = {3, 5, 6, 8};
	a = b;
	cout << (sizeof(b) / sizeof(b[0])) << endl; //4
	cout << (sizeof(a) / sizeof(a[0])) << endl; //2 < not 4!
	for (int i = 0; i < 4; i++) {
		cout << "[" << i << "] " << b[i] << " : " << a[i] << endl; //fine work
	}
    return 0;
}