-->

Program to know total memory occupied by struct using size of struct concept.

using codeblocks
--------------------------------------------------------------------------------------------------------------------------
Program to know total memory occupied by struct using size of struct concept.
----------------------------------------------------------------------------------------------------------
// program to use sizeof() in struct            //comment abt. program
#include <stdio.h>                                 //header file
struct data                                        //struct tag named data
{
    char name[80];                                //member1 of struct
    char address[80];                             //member2 of struct
    int roll;                                     //member3 of struct

};
struct data access={"rajan","Kalanki",34}; //'access' is a variable to access members. rajan,kalanki and 34 are data.
int main()
{

   printf("total memory is\n");
   printf("%d",sizeof(access));                  // display of total bytes used by struct, using access
    return 0;
}

---------------------------------------------------------------------------------------
using turbo c++
------------------------------------------------------------------------
// program to use sizeof() in struct            //comment abt. program
#include <stdio.h>                                 //header file
#include<conio.h>
struct data                                        //struct tag named data
{
    char name[80];                                //member1 of struct
    char address[80];                             //member2 of struct
    int roll;                                     //member3 of struct

};
struct data access={"rajan","Kalanki",34}; //'access' is a variable to access members. rajan,kalanki and 34 are data.
int main()
{

   printf("total memory is\n");
   printf("%d",sizeof(access));                  // display of total bytes used by struct, using access
getch();
    return 0;
}

No comments:

Post a Comment