-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproject_ask_fm_Q&A.cpp
More file actions
1413 lines (1145 loc) · 37.5 KB
/
Copy pathproject_ask_fm_Q&A.cpp
File metadata and controls
1413 lines (1145 loc) · 37.5 KB
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 <limits>
#include<iostream>
#include<bits/stdc++.h>
#include<sstream>
#include<fstream>
#include "lib.h"
using namespace std;
struct user
{
string name;
string password;
string email;
string path = "signed_up_users.txt";
int id;
// int len;
vector<int> login_users_vector;
vector<int> signed_in_users_vector;
// int return_the_last_line()
// {
// fstream file_handler(signed_up_users_path.c_str());
// string line;
// int line_num = 0;
// while (getline(file_handler, line))
// line_num++;
// return line_num;
// }
user()
{
name = "";
password = "";
email = "@gmail.com";
id = -1;
// len = return_the_last_line();
}
bool check_if_user_signed_up_by_id(int id)
{
fstream file_handler(signed_up_users_path.c_str());
if (file_handler.fail())
{
cout << "Can't open the login_users file!\n";
return false;
}
string line;
while (getline(file_handler, line))
{
if (extract_id_from_line(line) == id)
{
file_handler.close();
return true;
}
}
file_handler.close();
return false;
}
int generate_id_for_new_user()
{
update_signed_in_users_ids_vector();
int id;
for (size_t i = 0; i < signed_in_users_vector.size(); i++)
{
if (check_if_user_signed_up_by_id(i + 1)) continue;
id = i + 1;
return id;
}
id = signed_in_users_vector.size() + 1;
return id;
}
bool check_if_user_login_by_id(int id)
{
ifstream file_handler(current_login_users_path.c_str());
if (file_handler.fail())
{
cout << "Failed to open current_login_users file\n";
return false;
}
string line;
int loop = 1;
while (getline(file_handler, line))
{
if (extract_id_from_line(line) == id)
{
// cout << id << " " << return_user_id_from_line(line) << " " << loop << endl;
file_handler.close();
return true;
}
loop++;
}
if (extract_id_from_line(line) == -1) cout << "No users login at the moment\n";
file_handler.close();
return false;
}
string return_user_name_by_id(int id)
{
string name;
fstream file_handler(signed_up_users_path);
if (id == -2) return "Anonymous";
if (file_handler.fail())
{
cout << "Failed to open sign up users file\n";
return "Failed to open";
}
string line;
while (getline(file_handler, line))
{
int user_id = extract_id_from_line(line);
if (user_id == id)
return extract_name_from_line(line);
}
return "Not Found User";
}
bool password_validation(string password)
{
if (password.size() < 8) return false;
int okay = 0;
bool upper = false;
bool number = false;
for (size_t i = 0; i < password.size(); i++)
{
if (password[i] >= (char) 65 && password[i] <= (char) 90)
okay++, upper = true;
if (password[i] >= (char) 48 && password[i] <= (char) 57)
okay++, number = true;
}
if (!upper) cout << "No upper case letter exists\n";
if (!number) cout << "No number exists\n";
if (okay < 8) cout << "Password should be at least 8 characters\n";
if (okay < 2 || !upper || !number) return false;
return true;
}
bool email_validation(string email)
{
int number = convert_char_to_signed_integer(email[0]);
if (email[0] == '@' || number != -1)
{
cout << "Email mustn't start with a number\n";
return false;
}
string suffix = "gmail.com";
int found = false, index = 0, dot = 0;
for (size_t i = 0; i < email.size(); i++)
{
if (email[i] == '.' && !found)
{
cout << "Email can't contain dot before @\n";
return false;
}
if (is_symbol(email[i]) && email[i] != '@' && email[i] != '.') {
cout << "Email mustn't contain a symbol\n";
return false;
}
if (email[i] == '.') dot++;
if (dot > 1)
{
cout << "Email can't contain more than one dot (.)\n";
return false;
}
if (email[i] == '@') { found++; continue; }
if (!found) continue;
if (found > 1)
{
cout << "Email can't contain more than one '@'\n";
return false;
}
if (email[i] != suffix[index]) {
cout << "Email should be like name@gmail.com\n";
return false;
}
index++;
}
if (!found) {
cout << "Email should be like name@gmail.com\n";
return false;
}
return true;
}
bool name_validation(string name)
{
if (name[0] < 'A' || name[0] > 'Z')
{
cout << "Name should begin with capital letter\n";
cout << name[0] << " " << 'N' << endl;
return false;
}
for (size_t i = 1; i < name.size(); i++)
{
if (is_symbol(name[i]) || convert_char_to_signed_integer(name[i]) != -1)
{
cout << "Name shouldn't contain a symbol or a number\n";
return false;
}
if (name[i] >= 'A' && name[i] <= 'Z')
{
cout << "Name shouldn't contain a capital letter in the middle\n";
return false;
}
}
return true;
}
string return_signed_up_user_line_by_id(int id)
{
fstream file_handler(signed_up_users_path.c_str());
if (file_handler.fail())
{
cout << "Can't open login_users file\n";
return "Error";
}
string line;
string id_ = "";
while (getline(file_handler, line))
{
for (size_t i = 0; i < line.size(); i++)
{
if (line[i] == ' ') break;
id_ += line[i];
}
if (convert_string_to_integer(id_) == id)
{
file_handler.close();
return line;
}
id_ = " ";
}
file_handler.close();
return "error";
}
int check_if_user_signed_up_by_email_and_return_his_id(string email)
{
fstream file_handler(path.c_str());
if (file_handler.fail())
{
cout << "Couldn't open the user_signed_up file\n";
return -1;
}
string line, l_;
while (getline(file_handler, line))
{
string email_ = extract_email_from_line(line);
if (email == "email doesn't exists in the line") continue;
if (email_ == email)
{
l_ = line;
break;
}
}
int id_ = extract_id_from_line(l_);
return id_;
}
bool sign_up()
{
if (signed_in_users_vector.size() == MAX_USERS)
{
cout << "Can't add more users!\n";
return false;
}
cout << "Enter username, password, email:\n";
cin >> name >> email >> password;
name_validation(name);
email_validation(email);
password_validation(password);
if (!name_validation(name) || !password_validation(password) || !email_validation(email))
return sign_up();
if (check_if_user_signed_up_by_email_and_return_his_id(email) != -1)
{
cout << "This email already signed up!\n";
return sign_up();
}
bool visible_account = false;
cout << "Do you want your answers and questions to be visible to other users?\n";
cout << "Enter 1 for yes and 0 for no\n";
cin >> visible_account;
int id;
if (visible_account)
{
id = generate_id_for_new_user();
cout << "Your id is: " << id << endl;
}
else
{
id = 0;
cout << "You don't have id, Some operations won't be available for you\n";
}
fstream file_handler(signed_up_users_path.c_str(), ios::app);
if (file_handler.fail())
{
cout << "Failed to open signed up users file\n";
return false;
}
// int lines_number = return_file_lines_number(signed_up_users_path);
file_handler << id << " " << email << " " << name << " " << password << "\n";
cout << "You signed up to the system successfully!\n";
file_handler.close();
return true;
}
// COMPLETE THE REPLACE FUNCTION IN THE PROJECT lib.h
void reset_password(int id)
{
// string new_password;
// cout << "Enter the new password:\n";
// cin >> new_password;
// if (!password_validation(password))
// return reset_password(id);
// fstream file_handler(signed_up_users_path.c_str());
// string line; //don't use the return_signed_up_user_line_by_id function
// string id_ = ""; //because i need to edit on the file
// string password;
// while (getline(file_handler, line))
// {
// for (size_t i = 0; i < line.size(); i++)
// {
// if (line[i] == ' ') break;
// id_ += line[i];
// }
// // if (convert_string_to_integer(id_) == id)
// // {
// // password = return_password_from_signed_up_file(line);
// // // line.replace(line.find(password), line.length(), new_password);
// // }
// }
// THE RIGHT WAY :
// while (getline(file_handler, line)) { // Loop through each line in the input file
// size_t pos = line.find(searchWord); // Find the position of the search word in the line
// while (pos != std::string::npos) { // Repeat until all occurrences are replaced
// line.replace(pos, searchWord.length(), replaceWord); // Replace the search word with the replace word
// pos = line.find(searchWord, pos + replaceWord.length()); // Find the next occurrence of the search word
// }
// outputFile << line << "\n"; // Write the modified line to the output file
// }
}
void login(int trials = 3)
{
if (trials == 0)
{
cout << "Your attempts were wrong, Try later\n";
return;
}
if (trials < 3) cout << "Error in Password, Try again\n";
string email, password;
cout << "Enter your email and password\n";
cin >> email >> password;
int id = check_if_user_signed_up_by_email_and_return_his_id(email);
if (id == -1)
{
cout << "You are not signed up\n";
return;
}
string line = return_signed_up_user_line_by_id(id);
string name = extract_name_from_line(line);
string password_ = extract_password_from_sign_up_file(line);
if (password_ != password)
{
cout << "Wrong password, Try again\n";
return login(trials - 1);
}
fstream file_handler(signed_up_users_path.c_str());
string line_;
string user_line = "";
while (getline(file_handler, line_))
{
if (extract_id_from_line(line_) == id)
{
user_line = line_;
break;
}
}
fstream file_handler_2(current_login_users_path.c_str(), ios::app);
if (file_handler_2.fail())
{
cout << "Can't open current_login_users file\n";
return;
}
file_handler_2 << user_line << "\n";
file_handler_2.close();
cout << name << " login successfully!\n";
}
int read_user_info_for_sign_login_out()
{
int id;
string password;
cout << "Enter your id:\n";
cin >> id;
cout << "Enter your email and password to confirm its you:\n";
cin >> email >> password;
string l_ = return_signed_up_user_line_by_id(id);
if (l_ == "error" || l_.size() < 10)
{
cout << "Couldn't find the user\n";
return -1;
}
string email_ = extract_email_from_line(l_);
string password_ = extract_password_from_sign_up_file(l_);
if (password != password_)
{
cout << "Error in password, Try again\n";
return -1;
}
if (email != email_)
{
cout << "Email doesn't exists, Try again\n";
return -1;
}
return id;
}
bool logout()
{
int id = read_user_info_for_sign_login_out();
cout << "id: " << id << endl;
if (id == -1) return false;
if (!check_if_user_login_by_id(id))
{
cout << "This id is not logging\n";
return false;
}
fstream reader;
reader.open(current_login_users_path);
if (reader.fail())
{
cout << "Failed to open current_login_users file!\n";
return false;
}
vector <string>lines;
string line;
// bool found = false;
while (getline(reader, line))
{
if (extract_id_from_line(line) != id)
lines.push_back(line);
}
reader.close();
ofstream writer;
writer.open(current_login_users_path);
if (writer.fail())
{
cout << "Failed to open current_login_users file!\n";
return false;
}
for (size_t i = 0; i < lines.size(); i++)
writer << lines[i] << "\n";
return true;
}
//THIS METHOD IF USER WANTED TO UPDATE SIGNED UP USERS MANUALLY
void update_signed_in_users_ids_vector()
{
fstream file_handler(signed_up_users_path.c_str());
signed_in_users_vector.clear();
string line;
while (getline(file_handler, line))
signed_in_users_vector.push_back(extract_id_from_line(line));
file_handler.close();
}
//THIS FUNCTION IF USER WANTED TO UPDATE LOGIN USERS MANUALLY
void update_login_users_ids_vector()
{
fstream file_handler(current_login_users_path.c_str());
login_users_vector.clear();
string line;
while (getline(file_handler, line))
login_users_vector.push_back(extract_id_from_line(line));
file_handler.close();
}
//just to make sure that it is updating when a user signUp/logOut/signIn/Login
void print_vector()
{
for (size_t i = 0; i < signed_in_users_vector.size(); i++)
{
cout << signed_in_users_vector[i] << " ";
}
cout << "\n";
for (size_t i = 0; i < login_users_vector.size(); i++)
{
cout << login_users_vector[i] << " ";
}
}
bool sign_out()
{
int id = read_user_info_for_sign_login_out();
if (id == -1) return false;
if (!check_if_user_signed_up_by_id(id))
{
cout << "This id is not signed in\n";
return false;
}
// 11 fatima@gmail.com fatima fatiMa446543
char okay;
cout << "Are you sure you want to sign out? (y/n)\n";
cin >> okay;
if (okay == 'n') return false;
fstream reader;
reader.open(signed_up_users_path);
if (reader.fail())
{
cout << "Failed to open sign_in_users file!\n";
return false;
}
vector <string>lines;
string line;
while (getline(reader, line))
{
if (extract_id_from_line(line) != id)
lines.push_back(line);
}
reader.close();
ofstream writer;
writer.open(signed_up_users_path);
if (writer.fail())
{
cout << "Failed to open sign_in_users file!\n";
return false;
}
for (size_t i = 0; i < lines.size(); i++)
writer << lines[i] << "\n";
return true;
}
void list_system_users()
{
fstream file_handler(signed_up_users_path.c_str());
if (file_handler.fail())
{
cout << "Failed to open sign up users file\n";
return;
}
string line;
while (getline(file_handler, line))
{
if (extract_id_from_line(line) == 0)
{
cout << "Anonymous User\n";
cout << "_________________________________________\n";
}
else {
cout << extract_name_from_line(line) << "\n";
cout << "\thas id: " << extract_id_from_line(line) << "\n";
cout << "\tand his/her email is: " << extract_email_from_line(line) << "\n";
cout << "_________________________________________\n";
}
}
}
};
struct question
{
int question_id;
int user_id;
string question_content;
int answers_num_available;
user user_;
//this will list all questions that asked with user id
string extract_question_by_id(int id)
{
fstream file_handler(questions_path);
if (file_handler.fail())
{
cout << "Sorry couldn't open questions file, We will fix this problem soon\n";
return "Error";
}
string line;
string required_line;
while (getline(file_handler, line))
{
if (extract_question_id(line) == id)
{
required_line = line;
break;
}
}
int spaces = 0;
string result = "";
for (size_t i = 0; i < required_line.size(); i++)
{
if (line[i] == ' ' && spaces < 2) { spaces++; continue; }
if (spaces < 2) continue;
result += line[i];
}
if (result == "") { file_handler.close(); return "Error"; }
file_handler.close();
return result;
}
string extract_answer_by_id(int id)
{
fstream file_handler(answers_path);
if (file_handler.fail())
{
cout << "Sorry couldn't open answers file, We will fix this problem soon\n";
return "Error";
}
string line;
string required_line;
while (getline(file_handler, line))
{
if (extract_question_id(line) == id) //this method works also in answers file
{
required_line = line;
break;
}
}
int spaces = 0;
string result = "";
for (size_t i = 0; i < required_line.size(); i++)
{
if (line[i] == ' ' && spaces < 2) { spaces++; continue; }
if (spaces < 2) continue;
result += line[i];
}
if (result == "") { file_handler.close(); return "Error"; }
file_handler.close();
return result;
}
bool check_if_question_belongs_to_user(int question_id, int user_id)
{
fstream file_handler(questions_path);
if (file_handler.fail())
{
cout << "Sorry couldn't open question file, We will fix this problem soon\n";
return false;
}
string line;
while (getline(file_handler, line))
{
if (extract_user_id_from_question_or_answer_file(line) == user_id)
if (extract_question_id(line) == question_id)
return true;
}
return false;
}
void print_all_questions()
{
fstream question_file_handler(questions_path.c_str());
if (question_file_handler.fail())
{
cout << "Sorry couldn't open questions file, We will fix this problem soon\n";
return;
}
fstream answers_file_handler(answers_path.c_str());
if (answers_file_handler.fail())
{
cout << "Sorry couldn't open answers file, We will fix this problem soon\n";
return;
}
string question_line;
string answer_line;
while (getline(question_file_handler, question_line))
{
int question_id = extract_question_id(question_line);
cout << "Question number " << question_id << " from user id " << extract_user_id_from_question_or_answer_file(question_line) << " Question: " << extract_question_by_id(extract_question_id(question_line)) << "\n";
while (getline(answers_file_handler, answer_line))
{
if (extract_question_id(answer_line) == question_id)
{
cout << "Answer: " << extract_answer_by_id(question_id) << "\n";
cout << "\n";
break;
}
}
}
question_file_handler.close();
}
//this will list all questions from the user that is asking
void print_questions_from_user(int user_id)
{
fstream question_file_handler(questions_path.c_str());
if (question_file_handler.fail())
{
cout << "Sorry couldn't open questions file, We will fix this problem soon\n";
return;
}
fstream answers_file_handler(answers_path.c_str());
if (answers_file_handler.fail())
{
cout << "Sorry couldn't open answers file, We will fix this problem soon\n";
return;
}
string question_line;
string answer_line;
while (getline(question_file_handler, question_line))
{
int question_id = extract_question_id(question_line);
int user_id_who_asked = extract_user_id_from_question_or_answer_file(question_line);
if (user_id_who_asked != user_id) continue;
cout << "Question number " << question_id << " From You, Question: " << extract_question_by_id(extract_question_id(question_line)) << "\n";
while (getline(answers_file_handler, answer_line))
{
int user_id_who_answered = extract_user_id_from_question_or_answer_file(answer_line);
string user_name_who_answered = user_.return_user_name_by_id(user_id_who_answered);
if (user_name_who_answered == "Not Found User")
user_name_who_answered = "Deleted Account";
if (extract_question_id(answer_line) == question_id)
{
cout << "Answered from: " << user_name_who_answered << " Answer: " << extract_answer_by_id(question_id) << "\n";
cout << "\n";
break;
}
}
}
question_file_handler.close();
}
int extract_answer_id_from_line(string line)
{
int spaces = 0;
string id = "";
for (size_t i = 0; i < line.size(); i++)
{
if (line[i] == ' ' && spaces == 2) break;
if (line[i] == ' ') { spaces++; continue; }
if (spaces == 2)
id += line[i];
}
return convert_string_to_integer(id);
}
int return_new_id_for_new_answer(int question_id)
{
fstream file_handler(answers_path);
if (file_handler.fail())
{
cout << "Failed to open answers file\n";
return -1;
}
string line;
int new_id;
while (getline(file_handler, line))
{
//use extract_answer_id_from_line function
if (extract_question_id(line) == question_id)
new_id = extract_answer_id_from_line(line);
}
return new_id + 1;
}
bool answer_question(int question_id, int user_id)
{
string answer;
cout << "Enter your answer: \n";
getline(cin, answer);
fstream file_handler(answers_path.c_str(), ios::app);
if (file_handler.fail())
{
cout << "Failed to open answers_file\n";
return false;
}
int answer_id = return_new_id_for_new_answer(question_id);
if (answer_id <= 0)
{
cout << "invalid answer id\n";
return false;
}
file_handler << "\n" << question_id << " " << user_id << " " << answer_id << " " << answer;
file_handler.close();
cout << "Your answer added, Thank you!\n";
return true;
}
void delete_answer(int question_id, int user_id)
{
fstream reader;
reader.open(answers_path);
if (reader.fail())
{
cout << "Failed to open questions file!\n";
return;
}
vector <string>lines;
string line;
while (getline(reader, line))
{
int current_user_id = extract_user_id_from_question_or_answer_file(line);
if (extract_question_id(line) == question_id && current_user_id == user_id) continue;
lines.push_back(line);
}
reader.close();
ofstream writer;
writer.open(answers_path);
if (writer.fail())
{
cout << "Failed to open questions file!\n";
return;
}
for (size_t i = 0; i < lines.size(); i++)
writer << lines[i] << "\n";
// update_all_question_and_answer_ids(question_id, user_id);
//here i want to write a function that updates answer ids
}
void delete_all_answers_that_related_to_question(int question_id)
{
fstream reader;
reader.open(answers_path);
if (reader.fail())
{
cout << "Failed to open questions file!\n";
return;
}
vector <string>lines;
string line;
while (getline(reader, line))
{
if (extract_question_id(line) != question_id)
lines.push_back(line);
}
reader.close();
ofstream writer;
writer.open(answers_path);
if (writer.fail())
{
cout << "Failed to open questions file!\n";
return;
}
for (size_t i = 0; i < lines.size(); i++)
writer << lines[i] << "\n";
}
void delete_question(int question_id)
{
fstream reader;
reader.open(questions_path);
if (reader.fail())
{
cout << "Failed to open questions file!\n";
return;
}
vector <string>lines;