2 Replies - 1204 Views - Last Post: 18 November 2005 - 05:33 PM Rate Topic: -----

#1 mellowman83  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 13-October 05

trouble passing arguments to a function

Posted 18 November 2005 - 04:48 PM

i have failed to pass anything to this assignments function's , i tried going forward without solving that, but now i have reached the point where am unsure of my work as it has changed several times whilst trying to pass something.

to me those arrays are to be dealt with(initialized) within the functions and referred to other functions using numProds and numVends, but i havent been able to translate it into c++, yet.

i was able to pass the filename which the user at the time inputs in the main fnc and to the onloadDatabase, but only because all the array variables were only declared within the function and not as parameters of the function(i.e in the function title) as required by this assignment.

i am getting an error that the functions dont take 1 or 2 arguments, but i dont know what to do with all those other array variables.

could you please help me with this part. sorry for the long one here.

thanks in advance .

P.S: i have included the code as of 5:30 friday.

cheers

Attached File(s)



Is This A Good Question/Topic? 0
  • +

Replies To: trouble passing arguments to a function

#2 mellowman83  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 16
  • Joined: 13-October 05

Re: trouble passing arguments to a function

Posted 18 November 2005 - 04:56 PM

i thought i should incl the assignment restraints just in case i didnt make much sense.

just dealing with the functions is where am having the problems.

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#3 Amadeus  Icon User is offline

  • g+ + -o drink whiskey.cpp
  • member icon

Reputation: 248
  • View blog
  • Posts: 13,507
  • Joined: 12-July 02

Re: trouble passing arguments to a function

Posted 18 November 2005 - 05:33 PM

As mentioned before, you are getting the errors becasue your functions are declared to take several parameters, but you are only passing 1 or 2. You have to pass all the parameters to the function. This means that those arrays you are trying to pass must be declared and instantiated BEFORE you call the function, and you must pass them to the function.
For example, in your main function, you call the function here:
databaseLoad = onloadDatabase(numProds,numVends);


You are passing two parameters...the function, declared here:
bool onloadDatabase(char filename[50], char vNames[100][50], char prodDesc[100][30], long pCodes[100],
   	 double lPrices[100], long sPrices[100],	int stocks[100], int minQuan[100], int trgtQuan[100], 
   	 int pvCodes[100], int numProds, int vCodes[100], int vPhones[100], int numVends);


Is expecting 14. You must declare, instantiate, and pass those arrays to the function.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1