Skip to content

Commit 0bf66bf

Browse files
committed
add example of 'Typedef Keyword ' in C
1 parent f909238 commit 0bf66bf

File tree

2 files changed

+40
-18
lines changed

2 files changed

+40
-18
lines changed

a.out

-32 Bytes
Binary file not shown.

structure.c

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -125,31 +125,53 @@
125125
// }
126126

127127
// 🛑 Passing structure to function | Call by Reference 🌟 🌟 |
128+
// #include <stdio.h>
129+
// // user Difined
130+
// struct student {
131+
// char name [32];
132+
// int roll;
133+
// float cgpa;
134+
// };
135+
// void printInfo(struct student s1);
136+
// int main(){
137+
// struct student s1 = {"Programmer" , 302 , 3.4};
138+
// printInfo(s1); // Function call
139+
140+
141+
// s1.roll = 303;
142+
// printf("Student roll ; %d\n" , s1.roll);
143+
// return 0;
144+
// }
145+
// // Function Definition
146+
// void printInfo(struct student s1){
147+
// printf("print Information : ");
148+
// printf("Student Name is : %s\n" , s1.name);
149+
// printf("Student roll ; %d\n" , s1.roll);
150+
// printf("Student cgpa : %f\n" , s1.cgpa);
151+
// s1.roll = 303;
152+
// }
153+
154+
// Typedef Keyword
155+
128156
#include <stdio.h>
129-
// user Difined
130-
struct student {
131-
char name [32];
157+
#include <string.h>
158+
typedef struct CoumputerSceinceEngineearing{
159+
char name [22];
132160
int roll;
133161
float cgpa;
134-
};
135-
void printInfo(struct student s1);
162+
}CSE;
136163
int main(){
137-
struct student s1 = {"Programmer" , 302 , 3.4};
138-
printInfo(s1); // Function call
139-
164+
CSE s1;
165+
strcpy(s1.name,"Developer");
166+
s1.roll = 604;
167+
s1.cgpa = 2.6;
168+
printf("Student name is : %s\n" , s1.name);
169+
printf("Student roll : %d\n" , s1.roll);
170+
printf("Student cgpa : %f\n" , s1.cgpa);
140171

141-
s1.roll = 303;
142-
printf("Student roll ; %d\n" , s1.roll);
143172
return 0;
144173
}
145-
// Function Definition
146-
void printInfo(struct student s1){
147-
printf("print Information : ");
148-
printf("Student Name is : %s\n" , s1.name);
149-
printf("Student roll ; %d\n" , s1.roll);
150-
printf("Student cgpa : %f\n" , s1.cgpa);
151-
s1.roll = 303;
152-
}
174+
153175

154176
// #include <stdio.h>
155177
// int main(){

0 commit comments

Comments
 (0)