fork download
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. // khai bao struct
  5. struct sinhvien {
  6. char MSV[20]; // ma sinh vien
  7. char hoten[30]; // ho ten sinh vien
  8. double toan, tin, anh; // cac diem toan, tin, anh
  9. };
  10.  
  11. /* Hay thay tat ca __fpurge(stdin); thanh fflush(stdin) khi ban lam tren windowns*/
  12.  
  13. int main() {
  14. /* khai bao 2 bien sv1, sv2 va 1 mang
  15.   * CNPMK10A gom 100 sinh vien
  16.   */
  17. struct sinhvien sv1, sv2, CNPMK10A[100];
  18.  
  19. printf("Nhap du lieu cho sv1:\n");
  20. printf("MSV: "); __fpurge(stdin);
  21. gets(sv1.MSV);
  22. printf("Ho ten: "); __fpurge(stdin);
  23. gets(sv1.hoten);
  24. printf("Diem toan, tin, anh: "); __fpurge(stdin);
  25. scanf("%lf %lf %lf", &sv1.toan, &sv1.tin, &sv1.anh);
  26.  
  27. printf("Nhap du lieu cho sv2:\n");
  28. printf("MSV: "); __fpurge(stdin);
  29. gets(sv2.MSV);
  30. printf("Ho ten: "); __fpurge(stdin);
  31. gets(sv2.hoten);
  32. printf("Diem toan, tin, anh: "); __fpurge(stdin);
  33. scanf("%lf %lf %lf", &sv2.toan, &sv2.tin, &sv2.anh);
  34.  
  35. printf("\n --------- Thong tin sinh vien -----\n");
  36. printf("%-20s %-30s %-7s %-7s %-7s\n", "MSV", "Ho ten", "Toan", "Tin", "Anh");
  37. printf("%-20s %-30s %-7.2lf %-7.2lf %-7.2lf\n", sv1.MSV, sv1.hoten, sv1.toan, sv1.tin, sv1.anh);
  38. printf("%-20s %-30s %-7.2lf %-7.2lf %-7.2lf\n", sv2.MSV, sv2.hoten, sv2.toan, sv2.tin, sv2.anh);
  39.  
  40. return 0;
  41. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:20:36: error: ‘__fpurge’ was not declared in this scope
     printf("MSV: "); __fpurge(stdin);
                                    ^
prog.cpp:21:17: error: ‘gets’ was not declared in this scope
     gets(sv1.MSV);
                 ^
stdout
Standard output is empty