Skip to content

Instantly share code, notes, and snippets.

@s3f
Created January 11, 2017 16:42
Show Gist options
  • Save s3f/02e05ddc75ec3dc16d60162af0b4ebd4 to your computer and use it in GitHub Desktop.
Save s3f/02e05ddc75ec3dc16d60162af0b4ebd4 to your computer and use it in GitHub Desktop.
Chapter 27 - Structures created by s3f - https://repl.it/FEZW/10
/* Structures
In programming, if you want to store multiple values of a certain data type (integer, character, floating point etc), you use an array however, if you want to store data consisting of different kinds of data types, you can use a structure.
Here's how you would write it:
struct student {
char name [20];
int roll;
int age;
};
This is how you would create a structure variable:
struct student s1 = {"Bob", 3, 17};
This is how you would would access the struct variable:
printf("Name: %s \n", name, s1.name);
printf("Roll Number: %d\n"s1.roll);
printf("Age: %d \n", s1.age);
*/
// This header file defines a structure for information about a book
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment