help for writing codes

This is a discussion on help for writing codes within the C++ Programming forums, part of the General Programming Boards category; Write, CCompile and EExecute a C++ program that inputs a telephone number as a string in the form (392) 630-1234. ...

  1. #1
    Registered User
    Join Date
    Dec 2007
    Posts
    1

    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):
    Code:
     #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
    Output:
    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
    Posts
    3,211
    http://cmpe.emu.edu.tr/cmpe211/Fall_2006/Lab_Manual.pdf

    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
    Location
    Canada
    Posts
    1,243
    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 Cprogramming.com
    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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21