Help

i build this beginner code for my college project
and i had some errors
this a part of it:
# include <iostream>
# include <iomanip>
# include <string>
# include <fstream>
using namespace std;
void add_new_student(string Name[100],int Student_Number[100],long long int Mobile_Number[100],string Address[100],char Sex[100],string SNB[1000]);
void add_new_book(long long int ISBN_Number[1000],string Title[1000],int edition[1000],string author_name[1000],bool Borrowed_Or_Not[1000],string SNB[1000]);
void modify_student_info(string Name[100],int Student_Number[100],long long int Mobile_Number[100],string Address[100],char Sex[100],string SNB[1000]);
void modify_book_info(long long int ISBN_Number[1000],string Title[1000],int edition[1000],string author_name[1000],bool Borrowed_Or_Not[1000],string SNB[1000]);
void delete_student_info(string Name[100],int Student_Number[100],long long int Mobile_Number[100],string Address[100],string SNB[1000],char Sex[100]);
void delete_book_info(long long int ISBN_Number[1000],string Title[1000],int edition[1000],string author_name[1000],string SNB[1000], bool Borrowed_Or_Not);
void display_student_info(string Name[100],int Student_Number[100],long long int Mobile_Number[100],string Address[100],char Sex[100],string SNB[1000]);
void display_book_info(long long int ISBN_Number[1000],string Title[],int edition[1000],string author_name[1000],string SNB[1000],bool Borrowed_Or_Not);
void borrow_book(string Name[100],int Student_Number[100],long long int Mobile_Number[100],string Address[100],char Sex[100],long long int ISBN_Number[1000],string Title[1000],int edition[1000],string author_name[1000],bool Borrowed_Or_Not[1000],string SNB[1000]);
void store_list(string Name[100],int Student_Number[100],long long int Mobile_Number[100],string Address[100],char Sex[100],long long int ISBN_Number[1000],string Title[1000],int edition[1000],string author_name[1000],bool Borrowed_Or_Not[1000],string SNB[1000]);
void display_file_content();
int find (const string list[],int lingth,string search );
ofstream File_Content;
int NUM1,NUM2,NUM3,NUM4;
int main(){
int choice;
string Name[100],Address[100];
long long ISBN_Number[1000],Mobile_Number[100];
int Student_Number[100],edition[1000];
char Sex[100];
string Title[1000],author_name[1000],SNB[1000];
bool Borrowed_Or_Not[1000];
do{
cout <<"Choose a number and press enter: "<<endl
<<"1- Add a new student."<<endl
<<"2- Add a new book."<<endl
<<"3- Modify a specific student information."<<endl
<<"4- Modify a specific book information."<<endl
<<"5- Delete a specific student information."<<endl
<<"6- Delete a specific book information."<<endl
<<"7- Display a specific student information."<<endl
<<"8- Display a specific book information."<<endl
<<"9- Borrow a specific book."<<endl
<<"10- Store a list of all books borrowed by a specific student into a file."<<endl
<<"11- Display the content of the file."<<endl
<<"12- Exit"<<endl;
cin>>choice;
system("cls");
switch (choice){
case 1:add_new_student( Name, Student_Number, Mobile_Number, Address, Sex,SNB);break;
case 2:add_new_book( ISBN_Number , Title, edition ,author_name,Borrowed_Or_Not,SNB);break;
case 3:modify_student_info(Name, Student_Number, Mobile_Number, Address, Sex,SNB);break;
case 4:modify_book_info( ISBN_Number , Title, edition ,author_name,Borrowed_Or_Not,SNB);break;
case 5:delete_student_info(Name, Student_Number, Mobile_Number, Address,SNB,Sex);break;
case 6:delete_book_info( ISBN_Number , Title, edition ,author_name, SNB, Borrowed_Or_Not);break;
case 7:display_student_info(Name, Student_Number, Mobile_Number, Address, Sex,SNB);break;
case 8:display_book_info( ISBN_Number , Title, edition ,author_name,SNB, Borrowed_Or_Not);break;
case 9:borrow_book(Name, Student_Number, Mobile_Number, Address, Sex, ISBN_Number, Title, edition, author_name,Borrowed_Or_Not,SNB);break;
case 10:store_list (Name, Student_Number, Mobile_Number, Address, Sex, ISBN_Number, Title,edition, author_name, Borrowed_Or_Not,SNB);break;
case 11:display_file_content();
case 12: break;
default :cout << "Not a Valid Choice.\n"<< "Choose again.\n";cin>>choice;system("cls");break;}}
while (choice!=12);
return 0;
}
void add_new_student(string Name[100],int Student_Number[100],long long Mobile_Number[100],string Address[100],char Sex[100],string SNB[1000]){
char ch;
cout <<"Enter the number of students you want to add: ";
cin >>NUM1;
for (int i=0;i<NUM1;i++){
cout <<"Enter student's name (Include First name and Last name): ";
getline(cin, Name[i]);

cout << "Enter student's number(9 digits): ";
cin>>Student_Number[i];
while (to_string((Student_Number)[i]).length()!=9)
{cout << "Invalid Input.\n"
<< "Enter student's number(9 digits): ";
cin>>Student_Number[i];}

cout << "Enter student's address: ";
getline(cin, Address[i]);
cout << "Enter student's Mobile number(10 digits): ";
cin >>Mobile_Number[i];
while (to_string(Mobile_Number[i]).length()!=10)
{cout << "Invalid Input.\n"
<< "Enter student's Mobile number(10 digits): ";
cin>>Mobile_Number[i];}

cout << "Enter student's Sex(M or F): ";
cin >>Sex[i];
while (Sex[i]!='M'&&Sex[i]!='m'&&Sex[i]!='F'&&Sex[i]!='f'){
cout << "Invalid choice:\n"
<<"Enter student's Sex(M or F): ";
cin >> Sex[i];}
cout<<"Is the student borrowed a book(T/F): ";
cin>>ch;
while ((ch!='T')||(ch!='t')||(ch!='F')||(ch!='f')){
cout<<"Invalid Input.\n"
<<"The book is borrowed or not(T/F): ";}
if ((ch='T')||(ch='t'))
SNB[i]=Student_Number[i];
system ("pause");
system ("cls");
}}

Please edit for readability.
https://www.cplusplus.com/articles/jEywvCM9/
You need to define the functions for options 2-11:

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
void add_new_book(long long int ISBN_Number[1000], string Title[1000], int edition[1000],
		  string author_name[1000], bool Borrowed_Or_Not[1000], string SNB[1000])
{
}
void modify_student_info(string Name[100], int Student_Number[100],
			 long long int Mobile_Number[100], string Address[100],
			 char Sex[100], string SNB[1000])
{
}

void modify_book_info(long long int ISBN_Number[1000], string Title[1000],
		      int edition[1000], string author_name[1000],
		      bool Borrowed_Or_Not[1000], string SNB[1000])
{
}

void delete_student_info(string Name[100], int Student_Number[100],
			 long long int Mobile_Number[100], string Address[100],
			 string SNB[1000], char Sex[100])
{
}

void delete_book_info(long long int ISBN_Number[1000], string Title[1000],
		      int edition[1000], string author_name[1000], string SNB[1000],
		      bool Borrowed_Or_Not)
{
}
void display_student_info(string Name[100], int Student_Number[100],
			  long long int Mobile_Number[100], string Address[100],
			  char Sex[100], string SNB[1000])
{
}

void display_book_info(long long int ISBN_Number[1000], string Title[], int edition[1000],
		       string author_name[1000], string SNB[1000], bool Borrowed_Or_Not)
{
}

void borrow_book(string Name[100], int Student_Number[100],
		 long long int Mobile_Number[100], string Address[100], char Sex[100],
		 long long int ISBN_Number[1000], string Title[1000], int edition[1000],
		 string author_name[1000], bool Borrowed_Or_Not[1000], string SNB[1000])
{
}

void store_list(string Name[100], int Student_Number[100],
		long long int Mobile_Number[100], string Address[100], char Sex[100],
		long long int ISBN_Number[1000], string Title[1000], int edition[1000],
		string author_name[1000], bool Borrowed_Or_Not[1000], string SNB[1000])
{
}


void display_file_content()
{
}


int find(const string list[], int lingth, string search)
{
    return -1;
}


Have you learned about classes and structs? They could simplify the code here.
Hello kimoL,


PLEASE ALWAYS USE CODE TAGS (the <> formatting button), to the right of this box, when posting code.

Along with the proper indenting it makes it easier to read your code and also easier to respond to your post.

http://www.cplusplus.com/articles/jEywvCM9/
http://www.cplusplus.com/articles/z13hAqkS/

Hint: You can edit your post, highlight your code and press the <> formatting button. This will not automatically indent your code. That part is up to you.


You can use the preview button at the bottom to see how it looks.

I found the second link to be the most help.



You wrote:

i build this beginner code for my college project
and i had some errors


What errors and where? Post the actual error message. Explain what you are having a problem with.

As dhayden pointed out you are missing some functions. Hard to fine a problem if it should be in what is missing.

Try to avoid using global variables. Anything in the file can change them and then it is hard to track down.
1
2
ofstream File_Content;  // <--- Should be in the function that needs it.
int NUM1, NUM2, NUM3, NUM4;  // <--- Should be in "main" and passed to the functions that need them. 


Andy
Topic archived. No new replies allowed.