-
Notifications
You must be signed in to change notification settings - Fork 5
/
Learning-Management-System.cpp
1719 lines (1536 loc) · 35 KB
/
Learning-Management-System.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include <fstream>
#include <iostream>
#include <iomanip>
#include <string>
#include <stdlib.h>
using namespace std;
// this function will check whether credit hours are between 0 to 3 or not
bool isValidCreditHours(int credit_hours)
{
bool var1 = false;
if (credit_hours > 0 && credit_hours <= 3)
{
var1 = true;
}
return var1;
}
// this function will check whether course code is valid or not
bool isValidCourseCode(char course_code[])
{
bool values1 = 0, values2 = 0;
for (char i = 'A'; i <= 'Z'; i++)
{
if (course_code[0] == i)
{
values1 = 1;
}
}
for (char j = 'A'; j <= 'Z'; j++)
{
if (course_code[1] == j)
{
values2 = 1;
}
}
bool value = 0, value2 = 0, value3 = 0;
for (char b = '0'; b <= '9'; b++)
{
if (course_code[2] == b)
{
value = 1;
}
}
for (char c = '0'; c <= '9'; c++)
{
if (course_code[3] == c)
{
value2 = 1;
}
}
for (char d = '0'; d <= '9'; d++)
{
if (course_code[4] == d)
{
value3 = 1;
}
}
if (values1 == 1 && values2 == 1 && value == 1 && value2 == 1 && value3 == 1)
{
return 1;
}
else
{
return 0;
}
}
// this function will check whether semester is between 0 to 8 or not
bool isValidSemester(int semester)
{
bool var = false;
if (semester > 0 && semester <= 8)
{
var = true;
}
return var;
}
// this function will check whether course name is valid or not
bool isValidCourseName(char course_name[])
{
bool value = true;
int x = 0;
while (course_name[x] != '\0')
{
for (char y = '0'; y <= '9'; y++)
{
if (course_name[x] == y)
{
value = false;
}
}
x++;
}
return value;
}
//this function will calculate max index of integar array semList
int max_index(int semList[])
{
int a = 0, counter = 0;
while (semList[a] != 0)
{
counter++;
a++;
}
return --counter;
}
//this function will calculate the max index of string array
int max_index_regNo(string stdRegNoList[])
{
int a = 0, counter = 0;
while (stdRegNoList[a] != "\0")
{
counter++;
a++;
}
return --counter;
}
//this statement will declare edit_course and delete course for the whole program
string edit_course_code;
int flag = 0, counter = 0, counter2, flag2 = 0, counter3, flag3 = 0, counter4, check_1 = 0;
int var;
// this function will add course name, credit hours, semester and course code to nameList, crtHrsList, semList, codeList respectively
void AddCourse(string codeList[], string nameList[], int crtHrsList[], int semList[], char course_code[], int credit_hours, int semester, char course_name[])
{
static int n = var + 1;
static int c = 0;
int b = 0;
if (isValidSemester(semester) == 1 && isValidCourseCode(course_code) == 1 && isValidCreditHours(credit_hours) == 1 && isValidCourseName(course_name) == 1)
{
static int a = counter;
if (flag == 1)
{
// when a course is deleted, addCourse function will use this logic to add course details
b = counter;
codeList[b] = course_code;
crtHrsList[b] = credit_hours;
semList[b] = semester;
nameList[b] = course_name;
cout << "\nCourse has been added successfully" << endl;
b++;
flag = 2;
}
else if (var != 0)
{
if (flag == 2)
{
n = a + 1;
flag = 0;
}
//when there are already courses in an external file, addCourse function will use this logic to add new courses
codeList[n] = course_code;
crtHrsList[n] = credit_hours;
semList[n] = semester;
nameList[n] = course_name;
cout << "\nCourse has been added successfully" << endl;
n++;
}
else
{
//when there are no courses in the external file, addCourse function will use this logic to add new courses
if (flag == 2)
{
c = counter + 1;
flag = 0;
}
codeList[c] = course_code;
crtHrsList[c] = credit_hours;
semList[c] = semester;
nameList[c] = course_name;
cout << "\nCourse has been added successfully" << endl;
c++;
}
}
if (var == 0)
{
counter2 = c;
check_1 = 1;
}
else
{
counter2 = n;
check_1 = 1;
}
if (flag == 2)
{
counter2 = b;
check_1 = 1;
}
ofstream counter;
counter.open("AddCourse_Counter.txt");
counter << counter2 - 1;
counter.close();
}
//this function will check whether the course code which we want to edit is in the program.
int check_course_code(string codeList[], string edit_course_code)
{
bool value = 0;
for (int x = 0; x < 100; x++)
{
if (codeList[x] == edit_course_code)
{
value = 1;
break;
}
}
return value;
}
//this function will return the index where details of the course are placed
int index_course_code(string codeList[], string edit_course_code)
{
int index = -1;
for (int x = 0; x < 100; x++)
{
if (codeList[x] == edit_course_code)
{
index = x;
break;
}
}
return index;
}
//this function will return the index where details of the registration number are placed
int index_reg_code(string stdRegNoList[], string edit_reNo)
{
int index = -1;
for (int x = 0; x < 100; x++)
{
if (stdRegNoList[x] == edit_reNo)
{
index = x;
break;
}
}
return index;
}
//this function will return the index where registration number of the student is stored in 2D array
int index_stdCourseList(string stdCourseList[][100], string reg_No)
{
int index = -1;
for (int x = 0; x < 100; x++)
{
if (stdCourseList[x][0] == reg_No)
{
index = x;
break;
}
}
return index;
}
//this function will return us the index where the course is stored which we want to delete
int index_delete_code(string codeList[], string delete_course_code)
{
int index;
for (int x = 0; x < 100; x++)
{
if (codeList[x] == delete_course_code)
{
index = x;
break;
}
}
return index;
}
//this function will return us the max index of the row of the 2D array
int index_row(string stdCourseList[][100], string reg_No)
{
int x = 1, counter = 1;
int variable = index_stdCourseList(stdCourseList, reg_No);
while (stdCourseList[variable][x] != "\0")
{
counter++;
x++;
}
return counter;
}
//this function will replace a course of the specified course code with another course detail
void EditCourse(string codeList[], string nameList[], int crtHrsList[], int semList[], char course_code[], int credit_hours, int semester, char course_name[])
{
cout << "Enter the new details of the course: ";
cin >> course_code >> credit_hours >> semester;
cin.get(course_name, 100);
if (isValidSemester(semester) == 1 && isValidCourseCode(course_code) == 1 && isValidCreditHours(credit_hours) == 1 && isValidCourseName(course_name) == 1)
{
int n = index_course_code(codeList, edit_course_code);
codeList[n] = course_code;
crtHrsList[n] = credit_hours;
semList[n] = semester;
nameList[n] = course_name;
cout << "\nCourse has been edited successfully.\n";
}
else
{
cout << endl
<< "Invalid Course Details" << endl;
}
}
//this function will delete a course according to the course code which is given by the user
void DeleteCourse(string codeList[], string nameList[], int crtHrsList[], int semList[], string delete_course_code)
{
int n = index_delete_code(codeList, delete_course_code);
int m = max_index(semList);
for (int x = n; x <= m; x++)
{
codeList[x] = codeList[x + 1];
nameList[x] = nameList[x + 1];
crtHrsList[x] = crtHrsList[x + 1];
semList[x] = semList[x + 1];
}
codeList[m] = '\0';
nameList[m] = '\0';
crtHrsList[m] = '\0';
semList[m] = '\0';
flag = 1;
counter = m;
cout << endl
<< "Course has been deleted successfully" << endl;
}
int max_index_2(int crtHrsList[])
{
int a = 0, counter = 0;
while (crtHrsList[a] != 0)
{
counter++;
a++;
}
return counter;
}
// this function will display all the courses of a specific semester
void ViewSemesterCourse(string codeList[], string nameList[], int crtHrsList[], int semList[], int semester)
{
int size = max_index(semList);
cout << "Enter the semester of which you want to display course: ";
cin >> semester;
cout << endl;
cout << left;
cout << setw(15) << "\tCourse Code" << setw(30) << "Name" << setw(20) << "Credit Hours" << endl;
int index, x = 0;
while (semList[x] != 0)
{
if (semList[x] == semester)
{
cout << "\t" << setw(13) << codeList[x] << setw(31) << nameList[x] << setw(20) << crtHrsList[x] << endl;
}
x++;
}
}
//this function will save all the added courses in the file when we exit the program
bool saveCourses(string codeList[], string nameList[], int crtHrsList[], int semList[], int semester)
{
bool value = 0;
ofstream outData;
outData.open("Courses.txt");
int size = max_index(semList);
for (int x = 0; x <= size; x++)
{
outData << codeList[x] << "," << nameList[x] << "," << crtHrsList[x] << "," << semList[x] << endl;
value = 1;
}
outData.close();
return value;
}
//this function will load courses in memory when program is being loaded
bool loadCourses(string codeList[], string nameList[], int crtHrsList[], int semList[])
{
ifstream check, op;
check.open("check_for_loadCourses.txt");
int a, value1 = 0;
check >> a;
check.close();
op.open("AddCourse_Counter.txt");
int var;
op >> var;
op.close();
if (a == 1)
{
value1 = 1;
}
int x = 0, y = 0, creditHour, Semester, counter = 0;
string data;
ifstream inData;
inData.open("Courses.txt");
while (value1 == 1)
{
char courseCode[6] = {'\0'}, courseName[50] = {'\0'};
getline(inData, data);
while (data[x] != ',')
{
courseCode[y] = data[x];
y++;
x++;
}
codeList[counter] = courseCode;
x++;
y = 0;
while (data[x] != ',')
{
courseName[y] = data[x];
x++;
y++;
}
nameList[counter] = courseName;
x++;
while (data[x] != ',')
{
char conversion;
conversion = data[x];
creditHour = conversion - 48;
break;
}
crtHrsList[counter] = creditHour;
x += 2;
while (data[x] != '\0')
{
char con;
con = data[x];
Semester = con - 48;
break;
}
x++;
semList[counter] = Semester;
x = 0;
y = 0;
counter++;
if (counter > var)
{
break;
}
}
inData.close();
if (a == 0)
{
return 0;
}
else
{
return 1;
}
}
//this function will display all the courses ,which are added, on console
void ViewCourses(string codeList[], string nameList[], int crtHrsList[], int semList[])
{
int size;
size = max_index(semList);
cout << left;
cout << setw(15) << "\tCourse Code" << setw(30) << "Name" << setw(20) << "Credit Hours" << setw(20) << "Semester" << endl;
for (int i = 0; i <= size; i++)
{
cout << left;
cout << "\t" << setw(13) << codeList[i] << setw(31) << nameList[i] << setw(20) << crtHrsList[i] << setw(20) << semList[i] << endl;
}
}
//this function will check whether the inputed credentials are true or not
bool loadUsers(char usersList[], char passwordsList[])
{
ifstream users;
bool value = 0, value2 = 0;
char username[200] = {'\0'}, password[200] = {'\0'};
int x = 0;
string user;
cout << "Username: ";
cin >> username;
cout << "Password: ";
cin >> password;
users.open("Users.txt");
while (value == 0 && value2 == 0)
{
getline(users, user);
while (user[x] != ',')
{
if (user[x] == username[x])
{
value = 1;
}
else
{
value = 0;
break;
}
x++;
}
if (username[x] != '\0')
{
value = 0;
}
x++;
int y = 0;
while (user[x] != '\0')
{
if (user[x] == password[y])
{
value2 = 1;
}
else
{
value2 = 0;
break;
}
x++;
y++;
}
if (password[y] != '\0')
{
value2 = 0;
}
if (value == 1 && value2 == 1)
{
break;
}
if (user[x] == '\0')
{
break;
}
}
users.close();
if (value == 1 && value2 == 1)
{
return 1;
}
else
{
return 0;
}
}
//this function will check whether the entered registratoon number is valid or not
bool isValidRegistrationNumber(char regNo[])
{
bool value = 1, value2 = 0, value3 = 0, value4 = 0, value5 = 0, value6 = 0;
if (regNo[0] == '2' && regNo[1] == '0' && regNo[2] == '1' && regNo[4] == '-' && regNo[7] == '-' && regNo[11] == '\0')
{
for (char i = '0'; i < '9'; i++)
{
if (regNo[3] != i)
{
value = 0;
}
else
{
value = 1;
break;
}
}
for (char i = 'A'; i < 'Z'; i++)
{
if (regNo[5] == i)
{
value2 = 1;
}
}
for (char i = 'A'; i < 'Z'; i++)
{
if (regNo[6] == i)
{
value3 = 1;
}
}
for (char b = '0'; b <= '9'; b++)
{
if (regNo[8] == b)
{
value4 = 1;
}
}
for (char c = '0'; c <= '9'; c++)
{
if (regNo[9] == c)
{
value5 = 1;
}
}
for (char d = '0'; d <= '9'; d++)
{
if (regNo[10] == d)
{
value6 = 1;
}
}
}
else
{
value = 0;
}
if (value == 1 && value2 == 1 && value3 == 1 && value4 == 1 && value5 == 1 && value6 == 1)
{
return 1;
}
else
{
return 0;
}
}
//this function checks whether the entered student name is valid or not
bool isValidStudentName(char studentName[])
{
bool value = true;
int x = 0;
while (studentName[x] != '\0')
{
for (char y = '0'; y <= '9'; y++)
{
if (studentName[x] == y)
{
value = false;
}
}
x++;
}
return value;
}
int var4, var6;
//this function will addstudent in an stdNameList
void addStudent(string stdNameList[], string stdRegNoList[], char studentName[], char regNo[])
{
static int variable = 0;
int a = counter3;
int b = counter3;
int an_flag = 0;
static int n = var6;
if (isValidRegistrationNumber(regNo) == 1 && isValidStudentName(studentName) == 1)
{
if (flag2 == 1)
{
//when a student is deleted, addStudent function will use this logic to add student
stdNameList[a] = studentName;
stdRegNoList[a] = regNo;
cout << "\nStudent has been added successfully" << endl;
a++;
flag2 = 2;
}
else if (var6 != 0)
{
if (flag2 == 2)
{
n = counter3 + 1;
flag2 = 0;
}
stdNameList[n] = studentName;
stdRegNoList[n] = regNo;
n++;
cout << "\nStudent has been added successfully" << endl;
}
else
{
//when we have to add students in the memory
if (flag2 == 2)
{
variable = counter3 + 1;
flag2 = 0;
}
stdNameList[variable] = studentName;
stdRegNoList[variable] = regNo;
variable++;
cout << "\nStudent has been added successfully" << endl;
}
}
if (var6 != 0)
{
var4 = n;
ofstream OUTDATA;
OUTDATA.open("AddStudent_counter.txt");
OUTDATA << n;
OUTDATA.close();
}
else
{
var4 = variable;
ofstream OUTDATA;
OUTDATA.open("AddStudent_counter.txt");
OUTDATA << variable;
OUTDATA.close();
}
}
string edit_reNo;
//this function will edit the student in the list
void updateStudent(string stdNameList[], string stdRegNoList[], char studentName[], char regNo[])
{
if (isValidRegistrationNumber(regNo) == 1 && isValidStudentName(studentName) == 1)
{
int variable = index_reg_code(stdRegNoList, edit_reNo);
stdNameList[variable] = studentName;
stdRegNoList[variable] = regNo;
cout << "\nStudent details have been edited successfully.\n";
}
}
int var7;
//this function will register courses for the student
void registerCourse(string stdRegNoList[], string stdCourseList[][100], string codeList[], string reg_No, string courseCode)
{
if (index_course_code(codeList, courseCode) == -1)
{
cout << "There is no course by this course code." << endl;
}
else
{
static int n = var7;
//when we add courses in new student registration number in stdCourseList
if (index_stdCourseList(stdCourseList, reg_No) == -1)
{
//this condition will be used to add courses in the index of deleted courses
if (flag3)
{
stdCourseList[counter4][0] = reg_No;
stdCourseList[counter4][1] = courseCode;
flag3 = 0;
}
else
{
if (var7 != 0)
{
static int x = n;
int y = 0;
stdCourseList[x][y] = reg_No;
y++;
stdCourseList[x][y] = courseCode;
x++;
}
else
{
static int x = 0;
int y = 0;
stdCourseList[x][y] = reg_No;
y++;
stdCourseList[x][y] = courseCode;
x++;
}
}
}
else if (var7 != 0)
{
int variable = index_stdCourseList(stdCourseList, reg_No);
if (variable != -1 && index_row(stdCourseList, reg_No) == 1)
{
stdCourseList[variable][1] = courseCode;
}
else if (variable != -1 && index_row(stdCourseList, reg_No) != 1)
{
int y = index_row(stdCourseList, reg_No);
stdCourseList[variable][y] = courseCode;
}
else
{
stdCourseList[n][0] = reg_No;
stdCourseList[n][1] = courseCode;
n++;
}
}
//when we add courses in existing student registration number
else
{
int variable = index_stdCourseList(stdCourseList, reg_No);
int y = index_row(stdCourseList, reg_No);
stdCourseList[variable][y] = courseCode;
}
cout << "Course has been registered for the student." << endl;
}
}
//this function will delete the student from the studentlist
void deleteStudent(string stdNameList[], string stdRegNoList[], string stdCourseList[][100], string reg_no)
{
int variable = index_reg_code(stdRegNoList, reg_no);
int variable2 = max_index_regNo(stdRegNoList);
for (int x = variable; x <= variable2; x++)
{
stdRegNoList[x] = stdRegNoList[x + 1];
stdNameList[x] = stdNameList[x + 1];
}
stdRegNoList[variable2] = "\0";
stdNameList[variable2] = "\0";
flag2 = 1;
counter3 = variable2;
//this condition will delete student reg number and his/her registered courses from the stdCourseList
if (index_stdCourseList(stdCourseList, reg_no) == -1)
{
}
else
{
int variable3 = index_stdCourseList(stdCourseList, reg_no);
int y = index_row(stdCourseList, reg_no);
counter4 = variable3;
for (int x = 0; stdCourseList[variable][x] != "\0"; x++)
{
stdCourseList[variable3][x] = "\0";
flag3 = 1;
}
}
cout << endl
<< "Student has been deleted successfully" << endl;
}
//this function will unregister the course for the student
void unRegisterCourse(string stdRegNoList[], string stdCourseList[][100], string reg_no, string courseCode)
{
int variable = index_reg_code(stdRegNoList, reg_no);
bool value = 1;
for (int i = 0; stdCourseList[variable][i] != "\0"; i++)
{
if (stdCourseList[variable][i] == courseCode)
{
stdCourseList[variable][i] = "\0";
value = 1;
break;
}
else
{
value = 0;
}
}
if (value == 0)
{
cout << endl
<< "There is no course registered for the student by this course code.\n";
}
else
{
cout << endl
<< "Course has been unregistered successfully.\n";
}
}
//this function will display all the registered students
void viewstudents(string stdRegNoList[], string stdNameList[])
{
cout << left;
cout << setw(30) << "\t Student Name"
<< "Registration Number" << endl;
for (int x = 0; stdRegNoList[x] != "\0"; x++)
{
cout << left;
cout << "\t" << setw(29) << stdNameList[x] << stdRegNoList[x] << endl;
}
}
//this function will return the index where details of the registration number are placed in 2D array
int index_cou_code(string stdCourseList[][100], string edit_reNo)
{
int index = -1;
for (int x = 0; x < 100; x++)
{
if (stdCourseList[x][0] == edit_reNo)
{
index = x;
break;
}
}
return index;
}
//this function will calculate the length of the name
int length_of_name(string studentName)
{
int e = 0, y = 0;
while (studentName[e] != '\0')
{
y++;
e++;
}
return --y;
}
ofstream DATA;
//this function will save student credentials in an external file
void std_cre(string stdNameList[], string stdRegNoList[])
{
DATA.open("students_credentails.txt");
int x = 0;
while (stdRegNoList[x] != "\0")
{
string studentName, regNo;
studentName = stdNameList[x];
regNo = stdRegNoList[x];
int b = length_of_name(studentName);
DATA << studentName[b - 2] << studentName[b - 1] << studentName[b] << ",";
DATA << regNo << endl;
x++;
}
DATA.close();
}
//this function will save students in an external file
void saveStudents(string stdRegNoList[], string stdNameList[], string stdCourseList[][100])
{
ofstream outdata;
outdata.open("Students.txt");
for (int x = 0; stdRegNoList[x] != "\0"; x++)
{
string f = stdRegNoList[x];
outdata << stdRegNoList[x] << "," << stdNameList[x] << endl;
if (index_cou_code(stdCourseList, f) == -1)
{
outdata << endl;
}
else
{
int j = index_cou_code(stdCourseList, f);
for (int i = 1; stdCourseList[j][i] != "\0"; i++)
{
outdata << stdCourseList[j][i];
if (stdCourseList[j][i + 1] != "\0")
{
outdata << ",";
}
}
outdata << endl;
}
}
outdata.close();
}
//this function will load the students in the external file in the memory
void loadsStudents(string stdRegNoList[], string stdNameList[], string stdCourseList[][100])
{