Last active
September 7, 2018 18:45
-
-
Save Nahiduzzaman/e96f83ad9f671a985dace20072aad58d to your computer and use it in GitHub Desktop.
Revisions
-
Nahiduzzaman revised this gist
Sep 7, 2018 . 1 changed file with 21 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -56,3 +56,24 @@ int main(){ scanf("%d", &person1.age); printf("Age : %d", person1.age); } Fact 3 Access structur member through pointer #include<stdio.h> typedef struct personData { int age; float weight; } person; int main(){ person person1, *personPtr; person1.age = 12; person1.weight = 56.9; personPtr = &person1; printf("%d \n", personPtr->age); // you use -> only when the variable is pointer printf("%.1f", personPtr->weight); } -
Nahiduzzaman revised this gist
Sep 7, 2018 . 1 changed file with 23 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,6 @@ https://www.programiz.com/c-programming/c-structures Fact 1: Struct Example without typedef: @@ -33,3 +36,23 @@ int main(){ p1.weight = 57.9; printf("Age %d", p1.age); } Fact 2: Struct Input: #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 person1; printf("Enter age : "); scanf("%d", &person1.age); printf("Age : %d", person1.age); } -
Nahiduzzaman created this gist
Sep 6, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ 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); }