Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #define SIZE 20
- #define MAX 100
- void input(struct StudentInfo *student);
- void print(struct StudentInfo *student);
- struct StudentInfo
- {
- char name[SIZE];
- int n;
- };
- int main()
- {
- struct StudentInfo *s;
- int n, i, max, maxPosition;
- printf("How many students? ");
- scanf("%d", &n);
- s = (struct StudentInfo *) malloc(n * sizeof (struct StudentInfo));
- getchar();
- for(i = 0; i < n; i++)
- {
- input(&s[i]);
- }
- for(i = 0; i < n; i++)
- {
- print(&s[i]);
- }
- free(s);
- return 0;
- }
- void input(struct StudentInfo *student)
- {
- printf("Enter the name of stduent: ");
- gets(student->name);
- printf("Enter the number of student: ");
- scanf("%d", &student->n);
- getchar();
- }
- void print(struct StudentInfo *student)
- {
- printf("%s = %d\n", student->name, student->n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement