#include<iostream>
void sizes(char ch, int i, int* p)
{
std::cout<< "the size of char is " <<sizeof(char)<<' '<<sizeof (ch)<< '\n';
std::cout<< "the size of int is " <<sizeof(int)<<' '<<sizeof (i)<< '\n';
std::cout<< "the size of int* is " <<sizeof(int*)<<' '<<sizeof (p)<< '\n';
}
int main()
{
char a = 'a';
int x = 8, z = 9;
sizes('a', x , z);
}
I don`t know how to compile, there was in my book " Execute the example above and see what you get" .
#include<iostream>
void sizes(char ch, int i, int* p)
{
std::cout<< "the size of char is " <<sizeof(char)<<' '<<sizeof (ch)<< '\n';
std::cout<< "the size of int is " <<sizeof(int)<<' '<<sizeof (i)<< '\n';
std::cout<< "the size of int* is " <<sizeof(int*)<<' '<<sizeof (p)<< '\n';
}
int main()
{
char a = 'a';
int x = 8;
int* pi = &x;
sizes('a', x , pi );
}
Output:
the size of char is 1 1
the size of int is 4 4
the size of int* is 8 8
This is normal? I had to determine the size of char, int and int* ...