Size of Operator
Before going to the section on reading and writing of structures, I think I'll have to mention a little about the sizeof operator. This is a unary operator that returns the length in bytes of the variable that is mentioned in parentheses.
Whatever you what to find the size of, mention it within parentheses. The result will just be a number. For example the size of a character is 1 (i.e. 1 byte).
//
Using sizeof operator
#include <iostream>
using namespace std;
int main ( )
{
int a;
cout<<sizeof (a);
// Since a is an integer, the output will be 4
cout<<endl<<sizeof (char);
// Output will be 1
return 0;
}
Next section is on : Writing and Reading a structure from a file
or go back to Contents Page 2.