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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started