English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I get this error in passing an array when I call a function:

expected primary-expression before ']' token

Heres the switch statement:

switch(selection) //calls based on selection
{ //calls other functions
case 1: search(list[]);
break;
case 2: add(list[]);
break;
case 3: remove(list[]);
break;
case 4: update(list[]);
break;
//case 5: cout<<"Program Terminated"< // break;
default: cout<<"Make a valid selection 1-5 !!"< }//end switch

2006-09-14 06:46:22 · 3 answers · asked by Reaper0886 1 in Computers & Internet Programming & Design

3 answers

Perhaps you need to send list, not list[]. Like this:

case 1: search(list);


Using the [ ] brackets tells C++ you want to reference a specific position in the array, when in reality, you just want to pass the entire array (list).

2006-09-14 06:48:55 · answer #1 · answered by agbrisco 4 · 2 0

leve the brackets off all together. they idicate that you are trying to send a sinlge element form the array like list[1].

2006-09-14 07:28:56 · answer #2 · answered by Ralph 7 · 0 0

Hey.. remove the [ ] while passing parameter to the function.

2006-09-14 08:42:27 · answer #3 · answered by yaramala 2 · 0 0

fedest.com, questions and answers