Thread: Very odd compiling error...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    244

    Very odd compiling error...

    Or it seems odd to me.

    Here is the prototype of the function in question:

    Code:
    void getNumber(int &i);
    here is the definition:

    Code:
    void getNumber(int &ri)
    {
    	char a[256];
    	char *p;
    	int isNum;
    	int isSize;
    	
    	cout << endl << "Enter the NUMBER: ";
    	cin.get(a,256);
    	cin.ignore(80, '\n');
    	isNum = checkNumeric(a);
    	if(isNum == 1)
    	{
    		p = &a[0];
    		ri = atoi(p);
    		isSize = checkSize(ri);
    		if(isSize != 1)
    		{
    			ri = getNumber();
    		}
    	}
    	if(isNum == 0) 
    	{
    		ri = getNumber();
    	}
    }
    And here are the errors:

    Code:
    asef.cpp: In function `void getNumber(int&)': 
    asef.cpp:85: too few arguments to function `void getNumber(int&)' 
    asef.cpp:102: at this point in file 
    asef.cpp:102: void value not ignored as it ought to be 
    asef.cpp:85: too few arguments to function `void getNumber(int&)' 
    asef.cpp:107: at this point in file 
    asef.cpp:107: void value not ignored as it ought to be
    I'm quite rusty on references, but comparing my code to example code, I can't quite seem whats causing it. What could it be?

    P.S. -> checkNumeric checks to see if the user enter a number. If he/she/it didn't, it returns 0, if he does, it returns 1. checkSize makes sure the user doesn't enter a number too large for the int to handle - returns 0 if it is too big, 1 if it isn't.

  2. #2
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    that's easy, you make a recursive call to getNumber with no parameters inside the function. "too few parameters" get it?
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  3. #3
    Blank
    Join Date
    Aug 2001
    Posts
    1,034
    Usually the errors tell you. Just pick the one with
    lowest line number and go from there.
    getNumber takes a parameter and you are calling
    it with no parameters. It returns nothing and you are
    trying to use it's return.

  4. #4
    Refugee face_master's Avatar
    Join Date
    Aug 2001
    Posts
    2,052
    those erros point to later in your code after the prototype/definition i'd assume, so psot the code where you call this function...

  5. #5
    pronounced 'fib' FillYourBrain's Avatar
    Join Date
    Aug 2002
    Posts
    2,297
    plus, your "new" declaration of getNumber returns void and your recursive calls are setting a number equal to the function call
    "You are stupid! You are stupid! Oh, and don't forget, you are STUPID!" - Dexter

  6. #6
    Registered User
    Join Date
    Aug 2001
    Posts
    244
    Originally posted by FillYourBrain
    that's easy, you make a recursive call to getNumber with no parameters inside the function. "too few parameters" get it?
    d'OH! Thats what happens when you have week old code, change the return type of a function, and then lazily forget to check the code for correctness!

    Stupid me!

    By the way, thanks for the quick replies - I posted this like 5 minutes ago!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  2. Avoiding Global variables
    By csonx_p in forum Windows Programming
    Replies: 32
    Last Post: 05-19-2008, 12:17 AM
  3. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  4. Connecting to a mysql server and querying problem
    By Diod in forum C++ Programming
    Replies: 8
    Last Post: 02-13-2006, 10:33 AM
  5. using c++ in c code
    By hannibar in forum C Programming
    Replies: 17
    Last Post: 10-28-2005, 09:09 PM