Announcement

Collapse
No announcement yet.

HELP!! More programming problems

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • HELP!! More programming problems

    Ugh I'm totally not getting my C++...I have this assigment and its already a day late...can anyone help me out?

    Here are the requirements:

    Using a function with this header and data types (include function prototype):
    void arrayTst(int ary1[], const int ary2[], int sizeAry1, int sizeAry2)create a program that:
    Passes arguments from main to the function. (Arrays are loaded with values in main).
    Alters the contents of ary1 (in the function definition) and returns the data to main() to be displayed.
    Displays ary2 contents in the function definition.
    Displays the contents of ary1 in main after the function is called.

    I think I have this covered:

    Using both c-strings and the string class, ask for, get and display a first name (with no spaces), immediately followed by ask for, get and display a full name (with a space between first and last name).Using both c-strings and the string class, implement string concatenation, copying or assigning one string to another string, determining string length. Display the results of doing each.


    Code:
    #include <iostream>
    #include <string>
    using namespace std;
    
    int main()
    {
        char firstName[15];
        char fullName[30];
       
        cout << "Input first name and press enter:";
        cin >> firstName;
        cout <<endl << "You have entered:"
            << firstName << endl << endl;
       
        cout << "Input full name with no spaces and press enter:";
        cin >> fullName;
        cout << endl << " You have entered:" << fullName << endl << endl;
        return 0;
    }
    Why is it called tourist season, if we can't shoot at them?

  • #2
    I'm not clear on where you're stuck. I understand the assignments, but don't see where/why you've stopped fulfilling them.

    Did I at least answer your problems from the last post?
    Gigabyte P35-DS3L with a Q6600, 2GB Kingston HyperX (after *3* bad pairs of Crucial Ballistix 1066), Galaxy 8800GT 512MB, SB X-Fi, some drives, and a Dell 2005fpw. Running WinXP.

    Comment


    • #3
      Originally posted by Wombat View Post

      Did I at least answer your problems from the last post?

      Yes

      Using a function with this header and data types (include function prototype):
      void arrayTst(int ary1[], const int ary2[], int sizeAry1, int sizeAry2)create a program that:
      Passes arguments from main to the function. (Arrays are loaded with values in main).
      Alters the contents of ary1 (in the function definition) and returns the data to main() to be displayed.
      Displays ary2 contents in the function definition.
      Displays the contents of ary1 in main after the function is called.


      is what I need to do next, and I'm not sure how to go about doing it.
      Why is it called tourist season, if we can't shoot at them?

      Comment


      • #4
        Heres what another student interpeted what needed to be done:


        1) Use the supplied function prototype to populate the two arrays, and then use it again to re-populate the first array (all integers, not letters). This will require the copying of a new array to the original ary1.

        2) Create two character arrays, one with c-strings and the other with string class. One array will be used to hold a first name, and the second will hold the full name (with spaces).

        3) Concatenate (join) the two strings together and output the new (combined) string and total string length
        Why is it called tourist season, if we can't shoot at them?

        Comment


        • #5
          Originally posted by GT98 View Post
          Heres what another student interpeted what needed to be done:


          1) Use the supplied function prototype to populate the two arrays, and then use it again to re-populate the first array (all integers, not letters). This will require the copying of a new array to the original ary1.
          No, they're saying that main populates both arrays. The function edits ary1, and main prints it afterward. ary2 is printed by the function while it's running.

          For the rest of the stuff, I think you need your professor's input. The way you're reading it, it sounds like the purpose is for you to mix c-strings and std strings. BUT, I read it as "do this with c-strings, and then totally redo it with c++ string class, and see how much easier that is."
          Gigabyte P35-DS3L with a Q6600, 2GB Kingston HyperX (after *3* bad pairs of Crucial Ballistix 1066), Galaxy 8800GT 512MB, SB X-Fi, some drives, and a Dell 2005fpw. Running WinXP.

          Comment

          Working...
          X