---
title: "Whats a struct?"  
description: "Whats a struct?"  
author: "Tarun Kumar"  
published: 2015-07-23  
updated: 2020-09-18  
canonical: https://www.mindstick.com/interview/2723/whats-a-struct  
category: "iphone"  
tags: ["iphone", "ios", "objective c"]  
reading_time: 2 minutes  

---

# Whats a struct?

Structs are a C construct that allows for grouping of items into one variable. For example, if you wanted to store a date, you could use three separate variables for the day, month, and year. This approach would work if you had to store one or two dates. But if you’re writing a calendar application, for example, having to keep track of which month belonged with which year would be a nightmare. Fortunately, C structs allow you to group these values into one type.

**The syntax for a date struct might look like this:**

struct date {int month; int day; int year;};

## Answers

### Answer by Tarun Kumar

Structs are a C construct that allows for grouping of items into one variable. For example, if you wanted to store a date, you could use three separate variables for the day, month, and year. This approach would work if you had to store one or two dates. But if you’re writing a calendar application, for example, having to keep track of which month belonged with which year would be a nightmare. Fortunately, C structs allow you to group these values into one type.

**The syntax for a date struct might look like this:**

struct date {int month; int day; int year;};


---

Original Source: https://www.mindstick.com/interview/2723/whats-a-struct

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
