Thread: error ?

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    25

    Question error ?

    This is a snippet from a little calc program I'm working with,
    a function to get the surface area of a cube

    Code:
    long cubeSurf (long length, long width, long height)
    {
    long surf;
    long side1 = length * height;
    long side2 = length * width;
    long side3 = height * width;
    surf = (2 * side1) + (2 * side2) + (2 * side3);  // surface area
    return surf;
    }
    I get this error :
    C:\Dev-Cpp\Work\MathW.cpp
    [Warning] In function `int main()':
    67 C:\Dev-Cpp\Work\MathW.cpp
    too few arguments to function `long int
    283 C:\Dev-Cpp\Work\MathW.cpp
    at this point in file

    Can someone explain too few arguments ??
    Thanks...............


  2. #2
    1479
    Join Date
    Aug 2003
    Posts
    253
    I am a noob but it sounds like you problem is in int main while calling the function.
    Knowledge is power and I want it all

    -0RealityFusion0-

  3. #3
    1479
    Join Date
    Aug 2003
    Posts
    253
    if you post some more code I could try to help you out a little more. I think its a declaration problem. try using lont int or long double(I am unsure as to what variable type your using).
    Knowledge is power and I want it all

    -0RealityFusion0-

  4. #4
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    Post the FULL tect of the errors, please, not just the first 40 or so characters.

  5. #5
    Registered User
    Join Date
    Aug 2003
    Posts
    25

    ok

    RealityFusion :
    OK here's the whole thing so far....As it is it compiles fine
    I have the problem area commented out.........

    Code:
    #include <iostream>
    #include <cstdlib>
    #include <stdio.h>
    #include <cmath>
    
    using namespace std;
    
    
    double a, b, s, i;                                
    double A, l, w, h;
    long H, length, width, height;
    double side1, side2, side3;                   
    double C, base, high;                          
    double x, y, r;                                
    
    
    //                       "Define the Functions"
    
    double add (double a, double b)                  // Add Function
    {
    return a + b; 
    }
    
    double subtract (double a, double b)             // Subtract Function
    {
    return a - b;
    }
    
    double multiply (double a, double b)             // Multiply Function
    {
    return a * b;
    }
                           
    double divide (double x, double y)         // Divide Function
    {
    return x / y; 
    }
    
    //double mod (double x, double y)
    //{
    //return x % y;
    //}
    
    double exp (double a, double b, double s, double i)
    {
    s = 1; 
      for (i=1; i <=b; i++)                 // Exponential Function  
        s = s * a; 
    return s; 
    }
    
    double area (double base, double high)
    {
    	double A = 0;
    	A = base * high;                 // Area of a Square Function
    	return (A); 
    }
    
    double cubeVol (double l, double w, double h)
    {
    	double C = 0;
    	C = l * w *  h;                   // Volume of a Cube Function
    	return (C);
    }
    
    //long cubeSurf (long length, long width, long height)
    //{
    //long surf;
    //long side1 = length * height;
    //long side2 = length * width;
    //long side3 = height * width;
    
    //surf = (2 * side1) + (2 * side2) + (2 * side3);  // surface area
    //return surf;
    //}
    
    
    double sqroot (double x)        
    {                        
    return sqrt (x);                      // Square Root Function
    }
    
    
    //                  "Define the Screens"
    
    double addscreen ()         // Addition Screen
    {
    double sum;
    cout << "\n";
    cout << " Enter the 1st Number to Add : "; cin >> a;
    cout << " Enter the 2nd Number to add : "; cin >> b;
    sum = add (a, b);
    cout << "\n";
    cout << " Done ...The Sum is :  " << sum;
    cout <<"\n";
    //system ("pause");
    cin.get ();
    return 0;
    }
    
    double subscreen ()         // Subtraction Screen
    {
    double ans;
    cout <<"\n";
    cout << " Enter the Number to be Subtracted from : "; cin >> a;
    cout << " Enter the Amount to Subtract : "; cin>> b;
    ans = subtract (a, b);
    cout << "\n";
    cout << " Done ...The Answer is  : " << ans;
    cout << "\n";
    //system ("pause");
    cin.get ();
    return 0;
    } 
    
    double mulscreen ()         // Multiplication Screen
    {
    double prod;
    cout << "\n";
    cout << " Enter the Multiplicand  :"; cin >> a;
    cout << " Enter the Multiplier  :"; cin >> b;
    prod = multiply (a, b);
    cout << "\n";
    cout << " Done ...The Product is  : " << prod;
    cout << "\n";
    //system ("pause");
    cin.get ();
    return 0;
    } 
    
    double divscreen ()       // Division Screen
    {
    double q = 0;
    //double r = 0;
    cout << "\n";
    cout << " Enter the Dividend  "; cin >> x;
    cout << " Enter the Divisor  "; cin >> y;
    q = divide (x, y);
    //r = mod (x, y); 
    cout << "\n";
    cout << " Done...The Quotent is : " << q;
    //cout << " And the Remainder is :" <<r;
    cout << "\n";   
    //system ("pause");
    cin.get ();
    return 0;
    } 
    
    double expscreen ()      // Exponential Screen
    {
    double ans = 0 ;
    cout << "\n";
    cout << " Enter Number to be Raised : "; cin >> a; 
    cout << " Enter the power to Raise to : "; cin >> b;
    ans = exp (a,b,s,i);
    cout << "\n";
    cout << " Done :" << a <<"  Raised to the " << b 
    <<"  Power is :" << ans; 
    cout << "\n";   
    //system ("pause");
    cin.get ();
    return 0; 
    }
    
    double areascreen ()     // Area of a Square Screen
    {
    double A = 0;
    cout << "\n";
    cout << " Enter the Base : "; cin >> base; 
    cout << " Enter the Height : "; cin >> high;
    A = area (base, high);
    cout << "\n";
    cout << " Done :" << "The Area of the Square is  :  " << A << "  Square -> ft,inches,cent,etc."; 
    cout << "\n";   
    //system ("pause");
    cin.get ();
    return 0; 
    }
    
    double cubeVolscreen ()      // Volume of a cube screen
    {
    double C = 0;
    cout << "\n";
    cout << " Enter the Length : "; cin >> l;
    cout << " Enter the Height : "; cin >> h;
    cout << " Enter the Width  : "; cin >> w;
    cout << "        _ _ _ \n ";
    cout << "      /|   /| \n "; 
    cout << "     /_|_ / | \n "; 
    cout << "    |  |_ |_| \n ";
    cout << "    | /   | / \n ";
    cout << "    |/_ _ |/  \n ";    
    C = cubeVol (l, w, h);
    cout << "\n";
    cout << " Done :" << "The Volume of the Cube the is  :  " << C << "  Cubic -> ft,inches,cent,etc"; 
    cout << "\n";   
    //system ("pause");
    cin.get ();
    return 0; 
    }
    
    //long cubeSurfscreen ()
    //{
    //cout << "\n";
    //cout << " Enter the Length : "; cin >> length;
    //cout << " Enter the Height : "; cin >> height;
    //cout << " Enter the Width : "; cin >> width;
    //long H = 0;
    //H = cubeSurf (length, width, height);
    //cout << " Done : " << " The Surface Area of the Cube is : " << H << " Square -> ft, inches, cent, etc";
    //cout << "\n";
    //cin.get ();
    //return 0;
    //} 
    
    double rootscreen ()    // Square Root Screen
    {
    cout << " Enter Number to find Square Root of : ";
    cin >> x;
    r = sqroot (x);
    cout << " The Square Root of : " << x << " is " << r;
    cout << "\n";
    cin.get ();
    return 0;
    } 
    
    
    //                       "Main Function"
    
    int main ()
    {
    char choice;
    cout << " Choose your Math Function \n";
    cout << "\n";
    cout << " 1  : Addition \n"; 
    cout << " 2  : Subtraction \n";
    cout << " 3  : Multiplication \n";
    cout << " 4  : Division \n";  
    cout << " 5  : Area of a Square \n";
    cout << " 6  : Volume of a Cube \n";
    cout << " 7  : ** Surface Area of a Cube ** " << "\n";
    cout << "           Under Construction      \n"; 
    cout << " 8  : Exponents  \n";
    cout << " 9  : Square Root \n";
    cout << "\n"; 
    cout << " Enter your choice :";
    cin >> choice;
         switch (choice)
         {           
         case '1':
         addscreen ();
         break;
         case '2':
         subscreen ();
         break;
         case '3':
         mulscreen ();
         break;
         case '4':
         divscreen ();
         break;
         case '5':
         areascreen ();
         break;
         case '6':
         cubeVolscreen ();
         break;
    //     case '7':
    //     cubeSurf ();           // Under Construction
    //     break;
         case '8':
         expscreen ();
         break;
         case '9':
         rootscreen ();
         break;
         default:
         cout << " Your selection is not one of the above : Try again \n ";
         cout << "\n";
         system ("pause");
         system ("cls");
         return main ();
         }
         
    cout << "\n";     
    cout << "Do you wish to (C)ontinue or (E)xit\n";
    char restart; cin >> restart;
        switch (restart)
    	     {
    		case 'c':
    			system("CLS");
    			return main();
    			break;
    		case 'C':
    		     system ("cls");
    		     return main ();
    		     break;
    		case 'e':
    			return 0;
    			break;
    		case 'E':
    		     return 0;		     
                   break; 
    		}
    	
    return 0;
    }
    As you can see I was trying to add another function to the collection...........I'm adding them one at a time, but the function for the surface area of a cube is causing problems......maybe in the data type...I've used both long & double, but still get an error about too few arguments..........

  6. #6
    Registered User
    Join Date
    Aug 2003
    Posts
    25

    ok Cat

    Full compile log:
    Compiler: Default compiler
    Executing g++.exe...
    g++.exe "C:\Dev-Cpp\Work\MathW.cpp" -o "C:\Dev-Cpp\Work\MathW.exe" -g3 -O0 -ansi -g3 -I"C:\Dev-Cpp\include\c++" -I"C:\Dev-Cpp\include\c++\mingw32" -I"C:\Dev-Cpp\include\c++\backward" -I"C:\Dev-Cpp\include" -L"C:\Dev-Cpp\lib"
    C:/Dev-Cpp/Work/MathW.cpp: In function `int main()':
    C:/Dev-Cpp/Work/MathW.cpp:67: too few arguments to function `long int
    cubeSurf(long int, long int, long int)'
    C:/Dev-Cpp/Work/MathW.cpp:269: at this point in file

    Execution terminated

  7. #7
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    cubeSurf looks like this:

    long cubeSurf (long length, long width, long height)

    while in int main() you call it like this

    cubeSurf ();

    I think you probably wanted to use cubeSurfscreen in int main, didn't you ?
    Last edited by darksaidin; 08-23-2003 at 03:06 PM.

  8. #8
    Veni Vidi Vice
    Join Date
    Aug 2001
    Posts
    343
    O*G, next time someone ask you to post code post ONLY relevant code snippet. I doubt many people here will actually read the whole code. Anyway I will do my best to help you this time becuase you are using code tags .

    You are invoking function cubeSurf ();
    Code:
    //     case '7':
    //     cubeSurf ();           // Under Construction
    //     break;
    but the declaration looks like this
    Code:
    long cubeSurf (long length, long width, long height)
    thereof the error too few arguments to function `long int . Very describeable donīt you think . Iīm not saying that the function defintion is wrong but I think you are invoking(calling) the wrong function. My guess would be this
    Code:
    case '7':
    cubeSurfscreen ();
    break;
    Is mine guess right?

    P.S. Total area of a cube is very easy. The equation is CubeSurfArea = TotalNumbersOfSurfaces * length*length

    Damm beaten by darksaidin
    Last edited by ripper079; 08-23-2003 at 03:18 PM.
    01000111011011110110111101100100 011101000110100001101001011011100110011101110011 01100100011011110110111001110100 01100011011011110110110101100101 01100101011000010111100101110011 0110100101101110 01101100011010010110011001100101
    Good things donīt come easy in life!!!

  9. #9
    Registered User
    Join Date
    Aug 2003
    Posts
    25

    Thumbs up Duh

    ok I graciously accept my dose of "Duh am I stupid........
    THANKS all........that was it...(cubeSurfscreen)...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Getting an error with OpenGL: collect2: ld returned 1 exit status
    By Lorgon Jortle in forum C++ Programming
    Replies: 6
    Last Post: 05-08-2009, 08:18 PM
  2. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  3. Making C DLL using MSVC++ 2005
    By chico1st in forum C Programming
    Replies: 26
    Last Post: 05-28-2008, 01:17 PM
  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. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 01:10 AM