Skip to content

Instantly share code, notes, and snippets.

@Nahiduzzaman
Last active September 7, 2018 18:45
Show Gist options
  • Save Nahiduzzaman/e96f83ad9f671a985dace20072aad58d to your computer and use it in GitHub Desktop.
Save Nahiduzzaman/e96f83ad9f671a985dace20072aad58d to your computer and use it in GitHub Desktop.
Fact 1:
Struct Example without typedef:
struct person
{
int age;
float weight;
};
int main(){
struct person p1;
p1.age = 24;
p1.weight = 57.9;
printf("Age %d", p1.age);
}
Fact 2:
Struct Example with typedef:
#include <stdio.h>
typedef struct personData
{
int age;
float weight;
} person; // "personData" is the name of struct, "person" is alternative of struct type
// now you can use "person" to create struct object.
int main(){
person p1;
p1.age = 24;
p1.weight = 57.9;
printf("Age %d", p1.age);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment