Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS 0
- #include <stdio.h>
- #include <conio.h>
- #include <string.h>
- #include <time.h>
- #include <stdlib.h>
- struct SV
- {
- char HoTen[30];
- int Diem;
- };
- void nhap1SV(SV &SinhVien)
- {
- printf("Nhap vao ten SV: ");
- gets(SinhVien.HoTen);
- srand((unsigned) time(NULL));
- SinhVien.Diem=rand()%11;
- }
- void luuDanhSach(SV SinhVien, FILE* fp)
- {
- if (fp!=NULL)
- {
- fprintf(fp,"%s %i\n",SinhVien.HoTen, SinhVien.Diem);
- }
- }
- void main()
- {
- SV DanhSachSV[3];
- FILE *fp=fopen("DanhSachSV.txt","wt");
- for (int i=0; i<3; i++)
- {
- nhap1SV(DanhSachSV[i]);
- luuDanhSach(DanhSachSV[i],fp);
- }
- fclose(fp);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement