0

I expected a 9 but i am getting 12, can someone tell me why? char has size of 1 byte int has size of 4 byte float has size of 4 byte

#include<iostream>
using namespace std;

class test {
    int a;
    float b;
    char c;
};

int main() {
  cout << sizeof(test);
  return 0;
 }
Mat
  • 195,986
  • 40
  • 382
  • 396
  • 1
    https://stackoverflow.com/questions/119123/why-isnt-sizeof-for-a-struct-equal-to-the-sum-of-sizeof-of-each-member – Rish Apr 03 '22 at 19:32

0 Answers0