GOEDUHUB Online Courses || Last Batch Student's Projects || COVID-19 Projects(AI-ML) || Universities  ||  Placement Preparation  Subscribe our youtube channel
+91-7976731765 Free Online Tutorials ||  MACHINE LEARNING || NLP ||  OpenCV || Python || DBMS || OOPs || DSA || Java || Linux/Unix ||  C Programming
0 like 0 dislike
15 views
in Tutorial & Interview questions by Goeduhub's Expert (8k points)

_Alignof

Version ≥ C11

1 Answer

0 like 0 dislike
by Goeduhub's Expert (8k points)
 
Best answer

Queries the alignment requirement for the specified type. The alignment requirement is a positive integral power of 2 representing the number of bytes between which two objects of the type may be allocated. In C, the alignment requirement is measured in size_t.

The type name may not be an incomplete type nor a function type. If an array is used as the type, the type of the array element is used.

This operator is often accessed through the convenience macro alignof from <stdalign.h>.

int main(void) 

{    

printf("Alignment of char = %zu\n", alignof(char));    

printf("Alignment of max_align_t = %zu\n", alignof(max_align_t));    

printf("alignof(float[10]) = %zu\n", alignof(float[10]));    

printf("alignof(struct{char c; int n;}) = %zu\n", alignof(struct {char c; int n;}));    

}

Possible Output:

Alignment of char = 1 

Alignment of max_align_t = 16 

alignof(float[10]) = 4 

alignof(struct{char c; int n;}) = 4

Related questions

0 like 0 dislike
1 answer 8 views
0 like 0 dislike
0 answers 16 views
0 like 0 dislike
1 answer 16 views
0 like 0 dislike
1 answer 17 views
0 like 0 dislike
1 answer 5 views
 Placements:   List of companies | Logical Reasoning Questions | Quantitative Aptitude Questions | General English Questions | Technical-MCQ and Interview Questions
 Important Lists: List of NITsList of IITsList of Exams After Graduation | List of Engineering Entrance Examinations (UG/PG)College ReviewsCollege Fest, Events & WorkshopsKnowledge ShareTrainees/Interns After 15-04-2020
Exams & Cutoffs: JEE Main | JEE Advanced | GATE | IES | ISROList of PSUs || Cutoff-GATECutoff_IIT-JEECS-ScopeECE ScopeEE-Scope
 Download Previous Year Papers For:  GATE | IES | RAJASTHAN TECHNICAL UNIVERSITY (RTU-Kota)RPSC Technical Exams | ISRO
 Goeduhub
About Us | Contact Us   Social::   |  | 
...