347-600
2nd portionunknown
c_cpp
a month ago
10 kB
2
Indexable
void add_science_student() { FILE *student_above_8_science = fopen("above_class_8_science.txt", "r"); if (student_above_8_science == NULL) { student_above_8_science = fopen("above_class_8_science.txt", "w"); fclose(student_above_8_science); student_above_8_science = NULL; } else { int i = 0; while (fscanf(student_above_8_science, "\n%[^\n]", student_science[i].name1) == 1) { fscanf(student_above_8_science, "%d", &student_science[i].roll1); fscanf(student_above_8_science, "%d", &student_science[i].classs1); fscanf(student_above_8_science, "%s", student_science[i].section1); fscanf(student_above_8_science, "%d", &student_science[i].bangla_1st_2nd1); fscanf(student_above_8_science, "%d", &student_science[i].english_1st_2nd1); fscanf(student_above_8_science, "%d", &student_science[i].islam_and_moral1); fscanf(student_above_8_science, "%d", &student_science[i].bangladesh_and_global1); fscanf(student_above_8_science, "%d", &student_science[i].ict1); fscanf(student_above_8_science, "%d", &student_science[i].math1); fscanf(student_above_8_science, "%d", &student_science[i].highermath); fscanf(student_above_8_science, "%d", &student_science[i].physics); fscanf(student_above_8_science, "%d", &student_science[i].chemistry); fscanf(student_above_8_science, "%d", &student_science[i].biology); fscanf(student_above_8_science, "%d", &student_science[i].physical_education1); i++; } nos = i; fclose(student_above_8_science); } struct student_above_8_science a; gotoxy(30, 2); cout << "--Add Student Info & Result--" << endl; gotoxy(30, 4); cout << "Enter Name: "; cin.ignore(); cin.getline(a.name1, 100); gotoxy(30, 6); cout << "Enter Roll: "; cin >> a.roll1; gotoxy(30, 8); cout << "Enter Class: "; cin >> a.classs1; gotoxy(30, 10); cout << "Enter Section: "; cin >> a.section1; gotoxy(45, 14); cout << "--Enter Result--" << endl; gotoxy(7, 16); cout << "Enter The result of Bangla 1st & 2nd: "; cin >> a.bangla_1st_2nd1; gotoxy(7, 18); cout << "Enter The result of English 1st & 2nd: "; cin >> a.english_1st_2nd1; gotoxy(7, 20); cout << "Enter The result of Ialam and Moral Studies: "; cin >> a.islam_and_moral1; gotoxy(7, 22); cout << "Enter The result of Bangladesh and Global Studies: "; cin >> a.bangladesh_and_global1; gotoxy(7, 24); cout << "Enter The result of ICT: "; cin >> a.ict1; gotoxy(7, 26); cout << "Enter The result of Math: "; cin >> a.math1; gotoxy(65, 16); cout << "Enter The result of Higher Math: "; cin >> a.highermath; gotoxy(65, 18); cout << "Enter The result of Physics: "; cin >> a.physics; gotoxy(65, 20); cout << "Enter The result of Chemistry: "; cin >> a.chemistry; gotoxy(65, 22); cout << "Enter The result of Biology: "; cin >> a.biology; gotoxy(65, 24); cout << "Enter The result of Physical Education: "; cin >> a.physical_education1; student_science[nos] = a; nos++; FILE *above_8_student_science_add = fopen("above_class_8_science.txt", "w"); if (above_8_student_science_add != NULL) { for (int i = 0; i < nos; i++) { fprintf(above_8_student_science_add, "%s\n", student_science[i].name1); fprintf(above_8_student_science_add, "%d\n", student_science[i].roll1); fprintf(above_8_student_science_add, "%d\n", student_science[i].classs1); fprintf(above_8_student_science_add, "%s\n", student_science[i].section1); fprintf(above_8_student_science_add, "%d\n", student_science[i].bangla_1st_2nd1); fprintf(above_8_student_science_add, "%d\n", student_science[i].english_1st_2nd1); fprintf(above_8_student_science_add, "%d\n", student_science[i].islam_and_moral1); fprintf(above_8_student_science_add, "%d\n", student_science[i].bangladesh_and_global1); fprintf(above_8_student_science_add, "%d\n", student_science[i].ict1); fprintf(above_8_student_science_add, "%d\n", student_science[i].math1); fprintf(above_8_student_science_add, "%d\n", student_science[i].highermath); fprintf(above_8_student_science_add, "%d\n", student_science[i].physics); fprintf(above_8_student_science_add, "%d\n", student_science[i].chemistry); fprintf(above_8_student_science_add, "%d\n", student_science[i].biology); fprintf(above_8_student_science_add, "%d\n", student_science[i].physical_education1); } fclose(above_8_student_science_add); } else { setColor(4); gotoxy(30, 28); cout << "Error saving data!" << endl; setColor(7); } setColor(10); gotoxy(30, 28); cout << "Info Successfully Added" << endl; setColor(7); Sleep(1000); system("cls"); } void add_commerce_student() { FILE *student_above_8_commerce = fopen("above_class_8_commerce.txt", "r"); if (student_above_8_commerce == NULL) { student_above_8_commerce = fopen("above_class_8_commerce.txt", "w"); fclose(student_above_8_commerce); student_above_8_commerce = NULL; } else { int i = 0; while (fscanf(student_above_8_commerce, "\n%[^\n]", students_commerce[i].name2) == 1) { fscanf(student_above_8_commerce, "%d", &students_commerce[i].roll2); fscanf(student_above_8_commerce, "%d", &students_commerce[i].classs2); fscanf(student_above_8_commerce, "%s", students_commerce[i].section2); fscanf(student_above_8_commerce, "%d", &students_commerce[i].bangla_1st_2nd2); fscanf(student_above_8_commerce, "%d", &students_commerce[i].english_1st_2nd2); fscanf(student_above_8_commerce, "%d", &students_commerce[i].islam_and_moral2); fscanf(student_above_8_commerce, "%d", &students_commerce[i].bangladesh_and_global2); fscanf(student_above_8_commerce, "%d", &students_commerce[i].ict2); fscanf(student_above_8_commerce, "%d", &students_commerce[i].math2); fscanf(student_above_8_commerce, "%d", &students_commerce[i].accounting); fscanf(student_above_8_commerce, "%d", &students_commerce[i].finence); fscanf(student_above_8_commerce, "%d", &students_commerce[i].business_venture); fscanf(student_above_8_commerce, "%d", &students_commerce[i].physical_education2); i++; } nos = i; fclose(student_above_8_commerce); } struct student_above_8_commerce a; gotoxy(30, 2); cout << "--Add Student Info & Result--" << endl; gotoxy(30, 4); cout << "Enter Name: "; cin.ignore(); cin.getline(a.name2, 100); gotoxy(30, 6); cout << "Enter Roll: "; cin >> a.roll2; gotoxy(30, 8); cout << "Enter Class: "; cin >> a.classs2; gotoxy(30, 10); cout << "Enter Section: "; cin >> a.section2; gotoxy(45, 14); cout << "--Enter Result--" << endl; gotoxy(7, 16); cout << "Enter The result of Bangla 1st & 2nd: "; cin >> a.bangla_1st_2nd2; gotoxy(7, 18); cout << "Enter The result of English 1st & 2nd: "; cin >> a.english_1st_2nd2; gotoxy(7, 20); cout << "Enter The result of Ialam and Moral Studies: "; cin >> a.islam_and_moral2; gotoxy(7, 22); cout << "Enter The result of Bangladesh and Global Studies: "; cin >> a.bangladesh_and_global2; gotoxy(7, 24); cout << "Enter The result of ICT: "; cin >> a.ict2; gotoxy(7, 26); cout << "Enter The result of Math: "; cin >> a.math2; gotoxy(65, 16); cout << "Enter The result of Accounting: "; cin >> a.accounting; gotoxy(65, 18); cout << "Enter The result of Finance: "; cin >> a.finence; gotoxy(65, 20); cout << "Enter The result of Businiess Venture: "; cin >> a.business_venture; gotoxy(65, 22); cout << "Enter The result of Physical Education: "; cin >> a.physical_education2; students_commerce[nos] = a; nos++; FILE *above_8_student_commerce_add = fopen("above_class_8_commerce.txt", "w"); if (above_8_student_commerce_add != NULL) { for (int i = 0; i < nos; i++) { fprintf(above_8_student_commerce_add, "%s\n", students_commerce[i].name2); fprintf(above_8_student_commerce_add, "%d\n", students_commerce[i].roll2); fprintf(above_8_student_commerce_add, "%d\n", students_commerce[i].classs2); fprintf(above_8_student_commerce_add, "%s\n", students_commerce[i].section2); fprintf(above_8_student_commerce_add, "%d\n", students_commerce[i].bangla_1st_2nd2); fprintf(above_8_student_commerce_add, "%d\n", students_commerce[i].english_1st_2nd2); fprintf(above_8_student_commerce_add, "%d\n", students_commerce[i].islam_and_moral2); fprintf(above_8_student_commerce_add, "%d\n", students_commerce[i].bangladesh_and_global2); fprintf(above_8_student_commerce_add, "%d\n", students_commerce[i].ict2); fprintf(above_8_student_commerce_add, "%d\n", students_commerce[i].math2); fprintf(above_8_student_commerce_add, "%d\n", students_commerce[i].accounting); fprintf(above_8_student_commerce_add, "%d\n", students_commerce[i].finence); fprintf(above_8_student_commerce_add, "%d\n", students_commerce[i].business_venture); fprintf(above_8_student_commerce_add, "%d\n", students_commerce[i].physical_education2); } fclose(above_8_student_commerce_add); } else { setColor(4); gotoxy(30, 28); cout << "Error saving data!" << endl; setColor(7); } setColor(10); gotoxy(30, 28); cout << "Info Successfully Added" << endl; setColor(7); Sleep(1000); system("cls"); }
Editor is loading...
Leave a Comment