passing pointers/structures into function

Hey guys,I'm having trouble with passing my arrays into functions using structures. Specifically in my choice 1 part Not exactly sure how to go about it been trying to figure it out for a while now. Thanks in advance guys.

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
 #include <iostream>
#include <cstring>
using namespace std;

	struct Class{
	char title[50];
	int units;
	char grade;
	};
	void menu();
int add(struct Class ptr);
int main()
{
	char choice;
	Class point[10];
	Class* ptr[10];
	for (int i=0;i<=10;i++)
	{
		ptr[i] = &point[i];
	}
	do
	{
	 menu();
	 cin >> choice;
	 if (choice == '1')
		 add(ptr[10]);
	 else if (choice =='2')
		cout<< "choice works" << endl; //second thing
	 else if (choice =='3')
	 cout<< "choice works" << endl; // third thing
		else if (choice =='4')
		  cout<< "choice works" << endl; // fourth thing
		    else if (choice =='5')
			cout<< "choice works" << endl;// the other thing fifth
			 else if (choice =='6')
			cout<< "choice works" << endl; //sixth 
			  else if (choice =='7')
			 { cout << "quitting...." << endl;
			 choice = 7;
			 }
			  else 
			  cout << "invalid input" << endl;

	}while (choice !=7);// end of do
}
void menu()
{
	cout << "1. Add new class." << endl;
	cout << "2. Edit an existing class" << endl;
	cout << "3. Display a class" << endl;
	cout << "4. List all classes " << endl;
	cout << "5. Display GPA" << endl;
	cout << "6. Delete all classes" << endl;
	cout << "7. Quit." << endl;
}
int add(ptr[10])
{

}
Last edited on
Topic archived. No new replies allowed.