Member Avatar for zeLek

Below is the error I am currently facing however I have yet to be able to bring up the
console window to see if my code is correct. It has been very frustrating :(

1>iLab4.cpp(67): error C2144: syntax error : 'int' should be preceded by ')'
1>iLab4.cpp(67): error C2660: 'toDigit' : function does not take 0 arguments
1>iLab4.cpp(67): error C2059: syntax error : ')'
1>iLab4.cpp(68): error C2143: syntax error : missing ';' before '{'

    #include <iostream>
    #include <string>
    #include <cctype>
    #include <iomanip>
    using namespace std;

        char readDial(int & d);
        int toDigit(int & d);
        int acknowledgeCall();
        int phoneNumber;

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

    int toDigit(int & d)
     {
        toupper(d);
        switch(d)
          {
          case 'A': 
          case 'B': 
          case 'C': d = '2'; break;
          case 'D': 
          case 'E': 
          case 'F': d = '3'; break;
          case 'G': 
          case 'H': 
          case 'I': d = '4'; break;
          case 'J': 
          case 'K': 
          case 'L': d = '5'; break;
          case 'M': 
          case 'N': 
          case 'O': d = '6'; break;
          case 'P': 
          case 'Q': 
          case 'R': 
          case 'S': d = '7'; break;
          case 'T': 
          case 'U': 
          case 'V': d = '8'; break;
          case 'W': 
          case 'X': 
          case 'Y': 
          case 'Z': d = '9'; break;

        }
        cin >> phoneNumber;
     }

    char readDial(int & d)
    {
        cout << "Please enter a phone number: " << endl;
        phoneNumber = toDigit(int & d)
     {  
     if (phoneNumber == 'Q' || phoneNumber == 'q')
      {
       return -5;
      }
     }
    }
    int acknowledgeCall()
        {
        cout << "Phone number dialed: " << phoneNumber << endl;
    }

Recommended Answers

All 2 Replies

phoneNumber = toDigit(int & d)

Two small problems.

  1. Leave off the "int &". This is a function CALL, so leave off the type.
  2. You forgot the semicolon.

Try changing line 67 to this.

phoneNumber = toDigit(d);

OK, another problem. toDigit is supposed to return an int. It returns nothing. And if it returns an int and phoneNumber is an int, whya re you comparing it to a character in line 69? That's a legal comparison, but are you sure you want to do that?

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.