{
  "app": {
    "name": "Mokabla",
    "url": "https://www.mokabla.com",
    "description": "Real interview questions from companies in Egypt, organised by company. Access is sold per company for 30 days."
  },
  "page": {
    "kind": "question",
    "title": "Question · struct-padding",
    "humanPath": "/en/c/siemens/struct-padding",
    "humanOnly": false
  },
  "identity": {
    "class": "declared",
    "agent": "ClaudeBot",
    "operator": "Anthropic",
    "verified": false,
    "reason": "The user agent is ClaudeBot (Anthropic), which identifies itself as an AI agent.",
    "signals": [
      "Known agent user agent"
    ],
    "claimable": false
  },
  "state": {
    "question": {
      "slug": "struct-padding",
      "title": "Struct Padding",
      "difficulty": "easy",
      "tags": [
        "coding",
        "embedded",
        "technical",
        "swe"
      ],
      "is_free": true,
      "locked": false,
      "frequency": 1,
      "last_reported_at": "2026-07-15T18:54:56.479581Z",
      "url": "https://www.mokabla.com/en/c/siemens/struct-padding",
      "agent": {
        "page": "https://www.mokabla.com/agent/en/c/siemens/struct-padding",
        "question": "https://www.mokabla.com/agent/_call/get_question?company=siemens&question=struct-padding"
      },
      "company": {
        "slug": "siemens",
        "name_en": "Siemens (EDA / Digital Industries)"
      },
      "body_md": "## Problem\nI show you a C `struct` and ask for `sizeof` on a typical 32-bit target. Then I ask you to write a function that computes it: given the field types in declaration order, return the struct size with natural alignment padding.\n\nRules I state for the exercise: `char` is 1 byte / 1-aligned, `short` 2/2, `int` and `float` 4/4, `double` 8/8, pointers 4/4. Every field starts at an offset that is a multiple of its alignment, and the total size is rounded up to a multiple of the largest alignment in the struct.\n\n## Examples\n**Example 1**, `[\"char\", \"int\", \"char\"]`\n`char` at 0, then 3 bytes padding, `int` at 4-7, `char` at 8, tail padding to 12. Answer: `12`.\n\n**Example 2**, `[\"char\", \"char\", \"int\"]`\nSame fields, reordered: chars at 0 and 1, padding 2-3, `int` at 4-7. Answer: `8`. This is the point of the question: field order changes memory.\n\n**Example 3**, `[\"double\", \"char\"]` → `16`. `[\"char\"]` → `1`.\n\n## Constraints\n- 1 to 64 fields, only the types listed above.\n- No `#pragma pack`; ask me if you want to discuss what it would change.\n- Then explain: why does the compiler pad at all, and what happens on a Cortex-M if you read a misaligned `int` through a cast pointer.\n\n## What they look for\nCorrect offset arithmetic (`offset = roundUp(offset, align)`), remembering the tail padding, and being able to say **why** (bus access alignment, atomicity of aligned loads). Bonus points for mentioning `offsetof`, `_Alignof`, and that reordering fields by decreasing size minimises padding.",
      "follow_ups_md": "- Add a nested struct as a field type: its alignment is its largest member's.\n- What does `#pragma pack(1)` do to size and to access speed?\n- Bit-fields: how does the compiler lay out `unsigned a:3; unsigned b:5;`?"
    },
    "paid": false,
    "access": "Question bodies are paid content: a person buys 30 days of access per company (200 EGP or 200 points) in the human app. Agents get titles, tags and difficulty; bodies only for free questions."
  },
  "actions": [
    {
      "name": "get_question",
      "description": "One question with its body. Bodies are paid content unless the question is free.",
      "permission": "allow",
      "sideEffect": "read",
      "input": {
        "company": "string",
        "question": "string"
      },
      "href": "https://www.mokabla.com/agent/_call/get_question?company=siemens&question=struct-padding",
      "ready": true,
      "missing": [],
      "humanPath": "https://www.mokabla.com/en/pricing"
    },
    {
      "name": "list_questions",
      "description": "The questions reported at a company: titles, tags, difficulty, whether each is free or paid.",
      "permission": "allow",
      "sideEffect": "read",
      "input": {
        "company": "string",
        "page": "number?"
      },
      "href": "https://www.mokabla.com/agent/_call/list_questions?company=siemens",
      "ready": true,
      "missing": []
    },
    {
      "name": "buy_access",
      "description": "Buy 30 days of access to a company.",
      "permission": "block",
      "reason": "This action is for people only",
      "ruleId": "R1",
      "sideEffect": "payment",
      "input": {
        "company": "string"
      },
      "href": "https://www.mokabla.com/agent/_call/buy_access?company=siemens",
      "ready": true,
      "missing": [],
      "humanPath": "https://www.mokabla.com/en/pricing"
    },
    {
      "name": "post_comment",
      "description": "Comment on a question.",
      "permission": "block",
      "reason": "This action is for people only",
      "ruleId": "R1",
      "sideEffect": "write",
      "input": {
        "question": "string",
        "text": "string"
      },
      "href": "https://www.mokabla.com/agent/_call/post_comment?question=struct-padding",
      "ready": false,
      "missing": [
        "text"
      ],
      "humanPath": "https://www.mokabla.com/en/companies"
    }
  ],
  "navigate": [
    {
      "label": "This question, as data (free questions only)",
      "href": "https://www.mokabla.com/agent/_call/get_question?company=siemens&question=struct-padding"
    },
    {
      "label": "All questions at this company",
      "href": "https://www.mokabla.com/agent/_call/list_questions?company=siemens"
    },
    {
      "label": "The company page",
      "href": "https://www.mokabla.com/agent/en/c/siemens"
    },
    {
      "label": "Struct Padding · page",
      "href": "https://www.mokabla.com/agent/en/c/siemens/struct-padding"
    }
  ],
  "notices": [
    {
      "severity": "info",
      "message": "This classification is final for the session: it came from a strong signal, not a guess. The human pages are not served to agents."
    },
    {
      "severity": "info",
      "message": "Unverified agents are read-only. Signed requests (Web Bot Auth) are the path to write access."
    }
  ],
  "meta": {
    "requestId": "ag_9678681c3843",
    "policyVersion": "mokabla-2026-11-03",
    "generatedAt": "2026-11-03T18:38:20.301Z",
    "jsonUrl": "https://www.mokabla.com/agent/en/c/siemens/struct-padding?format=json",
    "manifestUrl": "https://www.mokabla.com/.well-known/agentgate.json",
    "humanUrl": "https://www.mokabla.com/en/c/siemens/struct-padding",
    "humanClaimUrl": "https://www.mokabla.com/agent/_claim/human?to=%2Fen%2Fc%2Fsiemens%2Fstruct-padding"
  }
}