L
LL
#include <stdio.h>
#include <stdlib.h>
struct Student {
int id;
char* name;
};
void getStudents(struct Student*, int);
void printStudents(struct Student*, int);
main() {
int n;
struct Student *s;
printf("Number of students: ");
scanf("%d", &n);
s=(struct Student*)malloc(n*(sizeof(struct Student)));
getStudents(s,n);
printStudents(s,n);
free(s);
exit(0);
}
void getStudents(struct Student *s, int n) {
for (int i=0; i<n; i++) {
printf("Student Name: ");
scanf("%s", s->name);
printf("Student ID: ");
scanf("%d", &s->id);
s++;
}
}
void printStudents(struct Student *s, int n) {
for(int i=0;i<n;i++) {
printf("Student Name: %s", s->name);
printf("ID: %d", s->id);
s++;
}
}
#include <stdlib.h>
struct Student {
int id;
char* name;
};
void getStudents(struct Student*, int);
void printStudents(struct Student*, int);
main() {
int n;
struct Student *s;
printf("Number of students: ");
scanf("%d", &n);
s=(struct Student*)malloc(n*(sizeof(struct Student)));
getStudents(s,n);
printStudents(s,n);
free(s);
exit(0);
}
void getStudents(struct Student *s, int n) {
for (int i=0; i<n; i++) {
printf("Student Name: ");
scanf("%s", s->name);
printf("Student ID: ");
scanf("%d", &s->id);
s++;
}
}
void printStudents(struct Student *s, int n) {
for(int i=0;i<n;i++) {
printf("Student Name: %s", s->name);
printf("ID: %d", s->id);
s++;
}
}