| | |
Passing Arrays to function in Visual C++
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Feb 2005
Posts: 6
Reputation:
Solved Threads: 0
This seems like a simple task but the microsoft visual c++ 6.0 compiler is giving me a problem with this. Its complaining about the lines where i try to use a passed array such as "fin[i]=0".
Its giving this error for the following code.
"error C2109: subscript requires array or pointer type"
<< moderator edit: added [code][/code] tags >>
Its giving this error for the following code.
"error C2109: subscript requires array or pointer type"
C++ Syntax (Toggle Plain Text)
void main() { ///// data structures for banker's ////////////////// //avaliable resources, actually only one, which is bank's Money. int r_avaliable; int curr_allocation[NUM_PROCESSES]; //current allocation of resources (money) to each Process (Client) int max[NUM_PROCESSES]; //max demand of each process int need[NUM_PROCESSES]; //remaining resource need of each process int request[NUM_PROCESSES]; //requests of clients for money. //used for safety algorithm int finish[NUM_PROCESSES]; int ret; ret = safety(r_avaliable, need, finish); } //end Main () int safety (int ava, int nd[], int fin[]) { //initialize work to avaliable, using ava so, OK. //initialize finish[i]= false for all i =1,2,3,etc.. for (int i=0; i<=NUM_PROCESSES; i++) { fin[i]=0; } //find i such that both, //finish[i]= false and //Needi <= Work (avaliable) for (int j=0; j <=NUM_PROCESSES; j++) { //look for an unmarked process if ((fin[j]==false) && (nd[j] < ava[1])) { //if found //A = A+Ci //Ci = 0; } //else else { //loop = false } } //end for return 1; } //end safety //function prototypes bool safety(int , int [NUM_PROCESSES] , int [NUM_PROCESSES]);
<< moderator edit: added [code][/code] tags >>
•
•
•
•
Originally Posted by F50
if ((fin[j]==false) && (nd[j] < ava[1]))
![]() |
Similar Threads
- Passing a member function pointer (C++)
- Problem when passing arrays from c# to matlab (C#)
- Passing arrays between subs (VB.NET)
- Help: Passing arrays between functions (C)
- passing arrays in visual basic (Visual Basic 4 / 5 / 6)
Other Threads in the C++ Forum
- Previous Thread: make directory
- Next Thread: Sorting
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class classes coding compile compiler console conversion count database delete deploy desktop developer directshow dll dynamiccharacterarray email encryption error file forms fstream function functions game getline givemetehcodez google graph homeworkhelp homeworkhelper iamthwee ifstream input int integer lib linkedlist linux list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference return rpg sorting string strings struct template templates text tree unix url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets





