[Error] too few arguments to function

In summary: This will allow the compiler to figure out where you are and start parsing the code.In summary, the problem is that you are not declaring the parameter types when you call the function.
  • #1
dect117
25
1
So I'm writing some code for a project and I'm stuck on the first part. This code is obviously unfinished, but I tried testing it just to see how it was coming along and I kept getting the [Error] too few arguments to function 'output_short_format'. As far as I can tell, I'm passing three arguments into the function which takes three arguments. I don't see the problem.
C:
#include <stdio.h>
#include <math.h>
void output_short_format (double, double, double);
int main () {
    int x, amount, int_rate, term, mon_int_rate;
    printf ("Welcome to Mortgage Calculator!\nPlease select from the options below.\n\n");
    printf ("For 'Short Format' press 1\n\nFor 'Amortized Schedule' press 2\n\nFor 'Monthly Early Payments' press 3\n\nFor 'Yearly Early Payments' press 4\n\n");
    printf ("Where would you like to go? ");
    scanf ("%d", &x);
    if (x=1) {
        system ("cls");
        printf ("---------------------------------\n");
        printf ("           LOAN TERMS\n");
        printf ("---------------------------------\n");
        amount = 150000;
        int_rate = 4;
        term = 15;
        printf ("Loan Amount: %15d\n", amount);
        printf ("Interest Rate: %12d%%\n", int_rate);
        printf ("Term: %16d years\n", term);
        printf ("---------------------------------\n\n");
        mon_int_rate = int_rate/1200;
        output_short_format (double amount, double mon_int_rate, double term);
    }
}
    void output_short_format (double loan_amount, double interest_rate, double term_years) {
    int months, p;
    months = term_years*12;
    p = (loan_amount*interest_rate*pow (1+interest_rate, months))/(pow (1+interest_rate, months)-1);
    printf ("Monthly payment is: %12d", p);
    printf ("Total interest is: %12d", interest_rate); \\ignore
    printf ("Total amount paid is: %12d", term_years); \\ignore
}
 
Last edited by a moderator:
Physics news on Phys.org
  • #2
Never mind, I figured it out.
 
  • #3
Just in case, the problem is when you called your function -- don't declare the parameter types when you call a function. The declarations of the parameters go in the function prototype (which you have in the third line) and in the function definition.

Also, I changed your opening code tags slightly, using [code=c] instead of just [code].
 

Related to [Error] too few arguments to function

1. What does it mean when I get the error message "too few arguments to function"?

When you receive the error message "too few arguments to function", it means that you have called a function without providing all of the required arguments. This means that the function is expecting a certain number of parameters to be passed in, but you have not provided enough.

2. Why am I getting the error message "too few arguments to function"?

The most common reason for getting this error message is that you have not provided enough arguments when calling a function. It could also be due to a mistake in the function definition, such as not declaring all of the required parameters.

3. How can I fix the "too few arguments to function" error?

To fix this error, you will need to provide the correct number of arguments when calling the function. Make sure to check the function definition to see how many parameters are required and pass them in accordingly.

4. Can a function have too many arguments?

Yes, a function can have too many arguments. However, this will not result in the "too few arguments to function" error. Instead, it will cause an "excess arguments" error, indicating that you have provided more arguments than the function is expecting.

5. Is there a way to prevent the "too few arguments to function" error?

Yes, you can prevent this error by carefully checking the function definition and making sure to provide the correct number of arguments when calling the function. You can also use default values for parameters in the function definition to avoid this error.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
1
Views
8K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
0
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
11
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
5
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
9
Views
3K
Back
Top