Skip to content

Commit

Permalink
11 | 12 - 18 | sharafat
Browse files Browse the repository at this point in the history
  • Loading branch information
SharafatKarim committed Aug 12, 2023
1 parent 753ca70 commit dfe3b42
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions solutions/sharafat/11/18.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,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;
}

0 comments on commit dfe3b42

Please sign in to comment.