How can I pass global variables into a function?

Problem with passing variable to function in C?

  • Hi all!! Have a little problem with a program im trying to get up and running i wont bore you all with the overview ill get to the heart of the matter. i have function call in my main program like this: dup (numin,lottopick,choice); and the function itself is void dup(int numin[],int lottopick,int choice) the problem (as he so adequately put it) is choice (sorry couldnt help it ;S ) the first array variables numin and lottopick work fine but as soon as i try to pass the value "choice" is shows too few arguenets to function 'dup' when i compile. Please help as im soooo close to the end of this program thanks in advance Drew

  • Answer:

    Too FEW arguments? I would have expected too MANY arguments. Without seeing the code, I suggest you make sure the function declaration for dup(), if any, matches the actual definition. If you don't have a definition, then the C compiler may be taking your first call instance as the (note: THE) declaration and dislikes any subsequent calls with different calling sequences. (This is a strong reason to use header files with overloaded calling sequences.) Hope that helps.

Franky Fish at Yahoo! Answers Visit the source

Was this solution helpful to you?

Other answers

I don't see the problem right away. Numin must be an array (passed by reference), and lottopick and choice are integers passed by value. Do all the data types match up?

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.