#include<stdio.h>
struct student {
char firstname[20];
char lastname[20];
char SSN[10];
float gpa;
}student;
main () {
struct student student_a;
strcpy(student_a.firstname,"deo");
strcpy(student_a.lastname,"dum");
strcpy(student_a.SSN,"23333234");
student_a.gpa=2009.20;
printf( "firstname: %s\n",student_a.firstname);
printf( "lastname: %s\n",student_a.lastname);
printf( "SSN: %s\n",student_a.SSN);
printf( "GPA: %s\n",student_a.gpa);
}
this code can be executed
but how if we use method "Pointers to Structs", what a piece of source i change...help me...
i was try to change a code like this
#include<stdio.h>
struct student {
char firstname[20];
char lastname[20];
char SSN[10];
float gpa;
}student;
main () {
struct student *student_a;
strcpy(student_a->firstname,"deo");
strcpy(student_a->lastname,"dum");
strcpy(student_a->SSN,"23333234");
student_a->gpa=2009.20;
printf( "firstname: %s\n",student_a->firstname);
printf( "lastname: %s\n",student_a->lastname);
printf( "SSN: %s\n",student_a->SSN);
printf( "GPA: %s\n",student_a->gpa);
}
help to fix my code...


Sign In
Create Account


Back to top









