sábado, 18 de enero de 2014

structure programs: C Program to Calculate Size of Structure using Sizeof Operator

#include<stdio.h>
#include<conio.h>
struct stud
{
int roll;
char name[10];
int marks;
};

void main()
{
int size;
struct stud s;
clrscr();
size = sizeof(s);
printf("nSize of Structure : %d",size);
getch();
}
Explanation :
size = sizeof(s);
Formula for Calculating Size of Structure :
Size of Structure 'S' = sizeof(roll) + sizeof(name) + sizeof(mark)
                      = 2 + 10 + 2
                      = 14

No hay comentarios:

Publicar un comentario