What will the given code print?
#include <iostream>

struct A {
  char a;
  int b;
  char c;
};

int main() {
  std::cout << sizeof(A);
}
Explanation
The size of the int type varies on different platforms. The size of the structure containing data types of various sizes depends on the type of alignment used by the compiler. The type of alignment may depend on the compiler settings.
Read more: Typical alignment of C structs on x86

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Cosmo
Sign Up Now
or Subscribe for future quizzes