cannot be used as a function

Good day, I keep getting this error whenever I want to call the function list(c) it says cannot be used as a function but whenever I use the function loop(a) and itemloop(b) it works perfectly fine here's the code for your reference, I bolded the part where the error is occurring too.


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

//functionzz//

	
char loop(int a){
char item[10][20], choice2;
int choice, i=0, itemloop, b, price[10];
	
		
	cout << "Welcome to my toy store!" << endl; 
	
	cout << "What can we do for you today?" << endl;
	
	cout << "[1] Enter Shop Items" << endl; 
	
	cout << "[2] List Shop Items" << endl; 
	
	cout << "[3] Buy Items" << endl; 
	
	cout << "[4] Exit Program" << endl; 
	
	cout << "Please enter your choice" << endl; 

    
    
}



//shop item//

int itemloop(int b){
char item[10][20], choice2, a;
int counter=1, choice, i=0, price[10], list, c;


    do {
	cout << "Enter description\n";
	cin >> item [i];
	cout << "Enter price\n";
	cin  >> price [i];
	cout << "Enter again? [Y/N]?" << endl; 
	cin >> choice2;
	++i;
  if (i==5){
  	cout << "error, max items reached\n";
   	cout << loop(a);
   }
}
   while ( choice2 == 'y' && counter !=5 );


   cout << loop(a);
   cin >> choice; 
   if (choice == 1)
   cout << itemloop(b);
   
   	if (choice == 2){
	cout << list(c);
    
    }
}




int list(int c){
char item[10][20], choice2, a, choice3;
int counter=1, choice, i=0, price[10], list;


	if (i==0){
	cout << "No items yet\n" << loop(a);
	}
	
	if (i==1){
	cout << "Item and price is: " << item[0] << " " << price[0]<< "\n";
	}
	if (i==2){
	
	cout << "Item and price is: " << item[1] << " " << price[1]<< "\n";
    }
	if (i==3){
	cout << "Item and price is: " << item[2] << " " << price[2]<< "\n";
    }
	if (i==4){
	cout << "Item and price is: " << item[3] << " " << price[3]<< "\n";
    }
	if (i==5){
	cout << "Item and price is: " << item[4] << " " << price[4]<< "\n";	
    }
    
    cout << "Go back to main menu? [Y/N]";
    
    cin >> choice3;
    
    if (choice3 == 'Y'|| choice3 == 'y'){
    	
    cout << loop(a);	
	}
	
	else if (choice3 == 'N' || choice3 == 'n'){
		cout << list(c);
    }
}

Last edited on
You failed to post compileable code.

Did you mean list[c] rather than list(c)?

You would have been better to continue on your previous thread
http://www.cplusplus.com/forum/general/277115/#msg1196093
Last edited on
My bad, sorry I'm just new here, I didn't know threads aren't deleted after some time 😅
Topic archived. No new replies allowed.