Character address size, "sizeof"
I get 4 bytes as the answer for each?
Why is the byte size of each address the same?
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#include<iostream>
using namespace std;
int main () {
int a;
char b;
double c;
cout<< sizeof &a<< endl;
cout<< sizeof &b<< endl;
cout<< sizeof &c<< endl;
return 0;
}
|
Thanks/ Kirk
You are getting the size of the address, not the actual type.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
|
#include<iostream>
using namespace std;
int main () {
int a = 100;
char b;
double c;
cout<< sizeof a<< endl; // remove address-of operator
cout<< sizeof b<< endl;
cout<< sizeof c<< endl;
return 0;
}
|
Thank you for your help!
Topic archived. No new replies allowed.