-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy path18.c
More file actions
41 lines (34 loc) · 708 Bytes
/
Copy path18.c
File metadata and controls
41 lines (34 loc) · 708 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <stdio.h>
#include <string.h>
struct person
{
char name[50];
int age;
float height;
};
int main()
{
struct person p1 = {
.name = "John",
.age = 25,
.height = 1.75,
};
printf("Original values:\n");
printf("Name: %s\n", p1.name);
printf("Age: %d\n", p1.age);
printf("Height: %.2f\n", p1.height);
char *name;
int *age;
float *height;
name = p1.name;
age = &p1.age;
height = &p1.height;
strcpy(name, "Sharafat");
*age = 30;
*height = 1.80;
printf("\nUpdated values:\n");
printf("Name: %s\n", p1.name);
printf("Age: %d\n", p1.age);
printf("Height: %.2f\n", p1.height);
return 0;
}