Crash_Override
Crash_Override

Reputation: 368

C++ Function Problem

I have gone over this back and forth and keep getting this error: 'ReadDials' : function does not take 0 arguments, can I get at least a point in the right direction?

#include <iostream>

using namespace std;

//declaring function
int ReadDials(int);

int main()
{
    //declaring each character of the phone number
    char num1, num2, num3, num4, num5, num6, num7, num8;
    bool quit = false;
    int code;

    while(quit != true || quit != true)
    ReadDials(code);
    if (code == -5)
        cout << "I love football!" << endl;
    else 
        return 0;
}

int ReadDials()
{
    //getting number from user
    cout << "Enter a phone number (Q to quit): ";
    cin >> num1;
    if (num1 == 'q' || num1 == 'Q')
    {
        code = -5;
        return code;
    }
    cin >> num2 >> num3 >> num4 >> num5 >> num6 >> num7 >> num8;
}

Upvotes: 0

Views: 257

Answers (4)

Felice Pollano
Felice Pollano

Reputation: 33252

Actually ReadDials takes 9 arguments, so you can't call ReadDials() without passing anithing to it. then, as far as I can see, the function "karma" seems to return the number the user "dials", but it will probably fail in this intent, since parameters are passed by value, so the function changes are not propagate outside. To achieve this you will probably better passa to the function a char*, or why not reading the whole number as a string ?

Upvotes: 3

justin
justin

Reputation: 104698

you must provide the arguments:

const int result(ReadDials(num1, num2, num3, num4, num5, num6, num7, num8, code));

Upvotes: 0

fredoverflow
fredoverflow

Reputation: 263128

readDials is declared as a function taking several parameters, so calling it without providing the corresponding arguments is an error.

Upvotes: 0

Jon
Jon

Reputation: 437376

You declare ReadDials to be a function with 9 arguments:

int ReadDials(char, char, char, char, char, char, char, char, int);

and then you call it providing none:

while(quit != true || quit != true)
ReadDials();

The compiler complains. Is that surprising?

Upvotes: 1

Related Questions