Thread: help for writing codes

  1. #1
    Registered User
    Join Date
    Dec 2007

    Exclamation help for writing codes

    Write, CCompile and EExecute a C++ program that inputs a telephone number as a
    string in the form (392) 630-1234. The program should use standard function strtok( )
    to extract the area code (sequence of digits shown in parentheses) as a token, the first three
    digits of the phone number as a token, and the last four digits of the phone number as a token. The seven
    digits of the phone number should be concatenated into one string containing no blanks. Both the area code
    and the phone number are then sent to the output.
    The initial part of the program may look as follows (You are free to follow it or to make certain modifications):
     #include <iostream >
    using namespace std;
    ... ... < other files for inclusion > ... ...
    #include <cstring >
    int main( )
    const int SIZE1 = 20;
    ... ... < other declarations, if needed > ... ...
    char p[ SIZE1 ];
    char * tokenPtr; // store temporary token
    char * areaCode; // store area code (token 1)
    char * phone; // store the phone number
    cout << "Enter a phone number in the form (555) 555-5555: ";
    cin.getline( p, SIZE1 );
    ... ... ... // remaining part of the program
    Hypothetical dialogue may have the form given below:
    Enter a phone number in the form (555) 555-5555: (392) 630-1234
    Area code (token 1) is 392
    Telephone number (concatenated tokens 2 and 3) is 6301234
    Last edited by Salem; 12-10-2007 at 03:43 AM. Reason: Fix positioning of code tags.

  2. #2
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007

    I like how you left this part out:

    (see pages 199-200 in the textbook)
    Lazy, lazy, lazy.

  3. #3
    Registered User
    Join Date
    Oct 2006
    i want to know how to write codes too!

    by the way, sonturk, without having even looked at your quote (quote, not question), were going to need you to do a little more before we offer any help (im already giving too much).

    we do not care what your assignment is word for word. if you want help, tell us what youve done, what went wrong/what was supposed to happen, and any code and error messages (those should be word for word!) that you have.

    now try again. help us help you.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Keyboard Codes
    By joeprogrammer in forum Game Programming
    Replies: 9
    Last Post: 02-22-2006, 07:15 PM
  2. codes
    By IfYouSaySo in forum A Brief History of
    Replies: 34
    Last Post: 11-18-2005, 03:09 PM
  3. action replay codes
    By c++.prog.newbie in forum Game Programming
    Replies: 2
    Last Post: 02-28-2004, 08:47 AM
  4. Key codes...
    By Supar in forum C++ Programming
    Replies: 3
    Last Post: 03-18-2003, 08:48 PM