SCHOOL OF CODE BUILDERS
Learn To CODE. Become A DEVELOPER.
Pages
HOME
DATA STRUCTURES
STRINGS
ARRAYS
MATRIX
BINARY TREES
LINKED LIST
STACK
QUEUE
SORTING
SEARCHING
C
PYTHON
PSEUDOCODE
CONTEST PROBLEMS
ALGORITHMS
PATTERNS
PHP
C PUZZLES
C INTERVIEW QUESTIONS
JAVA
C++
HASHING
RECURSION
BASIC C PROGRAMS
TCS-CODEVITA
FACEBOOK
CONTACT US
Find the size of the structure
Define a structure with members and thereby give the size of the allocated block of memory of the structure created.
Output:
size of the structure is sizeof(int) + sizeof(char) = 104 bytes
Implementation:
#include
#include
/* structure of student */ struct student { /* member variables */ int rollno; char name[100]; }; int main(void) { /* object 's' is created to access the allocated block of 104 bytes */ struct student s; /* collective size of the members of the structure student */ /* size of rollno (int type) & size of name (char array) */ printf("size of the structure is sizeof(int) + sizeof(char) = %d bytes ",sizeof(s)); return 0; }
PREVIOUS
NEXT
HOME