Question: C languages,i'm not sure why the printData function is not working properly #include #include struct Person{ char name[BUFSIZ]; char ssn[BUFSIZ]; int age; float height; float

C languages,i'm not sure why the printData function is not working properly

#include

#include

struct Person{

char name[BUFSIZ];

char ssn[BUFSIZ];

int age;

float height;

float weight;

};

void readData(struct Person x){

char buff[BUFSIZ];

printf("Name: ");

fgets(x.name,BUFSIZ,stdin);

printf("SSN: ");

fgets(x.ssn,BUFSIZ,stdin);

printf("Age: ");

x.age = atoi(fgets(buff,BUFSIZ,stdin));

printf("%d", x.age);

printf("Height: ");

x.height = atof(fgets(buff,BUFSIZ,stdin));

printf("%g", x.height);

printf("Weight: ");

x.weight = atof(fgets(buff,BUFSIZ,stdin));

printf("%g", x.weight);

}

void printData(struct Person x){

printf("Name = %s SSN = %s Age = %d Height(cm) = %g Weight(kg) = %g ", x.name, x.ssn, x.age, x.height, x.weight);

}

int main(){

struct Person x;

printf("Reading data ...... ");

readData(x);

printf(" ");

printf("Printing data .... ");

printData(x);

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!