Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C language, please help me fix the problem that i can;t print the data properly: #include #include struct Person{ char name[BUFSIZ]; char ssn[BUFSIZ]; int age;

C language, please help me fix the problem that i can;t print the data 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("Height: ");

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

printf("Weight: ");

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

}

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 a;

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

readData(a);

printf(" ");

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

printData(a);

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Shamkant B. Navathe

7th Edition Global Edition

1292097612, 978-1292097619

More Books

Students also viewed these Databases questions