Please Help Me! I cannot figure out what to do. I get an error that I don't understand. I posted my code and error below:

#include <iostream>
#include <string>
#include <iomanip>
#include <cctype>

using namespace std;

//prototypes
int read_dials(char &d1, char &d2, char &d3, char &d4, char &d5, char &d6, char &d7, char &d8);
int todigits(char &d);
void acknowledge_call(char d1, char d2, char d3, char d4, char d5, char d6, char d7, char d8);


int main()
{
        int read_dials(char &d);
        char returnValue = 0;

        while (returnValue != -5)
        {
            switch (returnValue)
            {
            case -1: cout << "ERROR - An invalid character was entered." << endl; break;
            case -2: cout << "ERROR - Phone number cannot begin with 0." << endl; break;
            case -3: cout << "ERROR - Phone number cannot begin with 555." << endl; break;
            case -4: cout << "ERROR - Hyphen is not in the correct position." << endl; break;

            [COLOR="red"]default: acknowledge_call();[/COLOR]           }
        } 
        return 0;
}


int read_dials(char &d1, char &d2, char &d3, char &d4, char &d5, char &d6, char &d7, char &d8)
{
    cout << "\nEnter a phone number (Q to quit):";
    cin >> d1;
    if (d1 == 'Q')
        return -5;
    cin >> d2 >> d3 >> d4 >> d5 >> d6 >> d7 >> d8;

    // call ToDigits function
    if (todigits(d1) == -1)
        return -1;
    if (todigits(d2) == -1)
        return -1;
    if (todigits(d3) == -1)
        return -1;
    if (todigits(d5) == -1)
        return -1;
    if (todigits(d6) == -1)
        return -1;
    if (todigits(d7) == -1)
        return -1;
    if (todigits(d8) == -1)
        return -1;
    if (d4 != '-')
        return -4;
    if (d1 == 0)
        return -2;
    if (d1 && d2 && d3 == 5)
        return -3;
    else
        return 0;
}


int todigits(char &d)
{
    toupper(d);

        switch (d)
        {
            case 'A':
            case 'B':
            case 'C': d = '2'; return 0; break;
            case '1': return 0; break;
            case 'D':
            case 'E':
            case 'F': d = '3'; return 0; break;
            case '2': return 0; break;
            case 'G':
            case 'H':
            case 'I': d = '4'; return 0; break;
            case '3': return 0; break;
            case 'J':
            case 'K':
            case 'L': d = '5'; return 0; break;
            case '4': return 0; break;
            case 'M': 
            case 'N':
            case 'O': d = '6'; return 0; break;
            case '5': return 0; break;
            case 'P':
            case 'Q':
            case 'R':
            case 'S': d = '7'; return 0; break;
            case '6': return 0; break;
            case 'T':
            case 'U':
            case 'V': d = '8'; return 0; break;
            case '7': return 0; break;
            case 'W':
            case 'X':
            case 'Y':
            case 'Z': d = '9'; return 0; break;
            case '8': return 0; break;
        }
}
void acknowledge_call(char d1, char d2, char d3, char d4, char d5, char d6, char d7, char d8)
{
    cout << "Phone Number Dialed:" <<  d1 << d2 << d3 << d4 << d5 << d6 << d7 << d8 << endl;
}

Here the error message:

1>.\Lab4.cpp(28) : error C2660: 'acknowledge_call' : function does not take 0 arguments

The problem area is highlighted in red

Recommended Answers

All 5 Replies

You have defined acknowledge_call to take eight arguments. You have called it with no arguments. Hence the error message.

Next time, please use code tags.

You have defined acknowledge_call to take eight arguments. You have called it with no arguments. Hence the error message.

Next time, please use code tags.

Sorry. I'm new to this. When I put that arguments in, I get like 3 more errors.

Please don't make us play guessing games: Show us exactly what you wrote, and tell us exactly what errors you got. And please use code tags.

This is the section of the code where the problem is occuring.

//prototypes
int read_dials(char &d1, char &d2, char &d3, char &d4, char &d5, char &d6, char &d7, char &d8);
int todigits(char &d);
void acknowledge_call(char d1, char d2, char d3, char d4, char d5, char d6, char d7, char d8);


int main()
{
        int read_dials(char &d);
        char returnValue = 0;

        while (returnValue != -5)
        {
            switch (returnValue)
            {
            case -1: cout << "ERROR - An invalid character was entered." << endl; break;
            case -2: cout << "ERROR - Phone number cannot begin with 0." << endl; break;
            case -3: cout << "ERROR - Phone number cannot begin with 555." << endl; break;
            case -4: cout << "ERROR - Hyphen is not in the correct position." << endl; break;

            default: acknowledge_call(char d1, char d2, char d3, char d4, char d5, char d6, char d7, char d8);          }
        } 
        return 0;
}

I added code and this is the error message I now get:

1>.\Lab4.cpp(28) : error C2144: syntax error : 'char' should be preceded by ')'
1>.\Lab4.cpp(28) : error C2660: 'acknowledge_call' : function does not take 0 arguments
1>.\Lab4.cpp(28) : error C2059: syntax error : ')'

When you call a function foo with an argument x that is a variable of type char, you call it by writing foo(x) , not foo(char x) . That's your first problem.

Your next problem is that the variables d1 through d8 are not declared at the point at which you have called acknowledge_call .

And your third problem is that you are still not using code tags.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.