Read first a user’s given name followed by the user’s age from standard input. Then use an ofstream object named outdata to write this information separated by a space into a file called outdata. Assume that this is the extent of the output that this program will do.

LANGUAGE: C++

CHALLENGE:

Read first a user’s given name followed by the user’s age from standard input. Then use an ofstream object named outdata to write this information separated by a space into a file called outdata. Assume that this is the extent of the output that this program will do.

SOLUTION:

The Bad News: The content you are trying to access is only available to members.

The Good News: You too can be a member, simply Click Here.

Already a member?

Posted in ,

3 Comments

  1. Jaclyn on October 12, 2015 at 4:26 pm

    There are too many “s in the solution. Here is the correct solution:
    string name;
    int age;

    cin >> name >> age;
    outdata.open(“outdata”);
    outdata << name << " " << age;
    outdata.close();

  2. Matt on October 14, 2015 at 9:49 pm

    The code has an error. Please use the code below for the correct program.

    string name;
    int age;

    cin >> name >> age;
    outdata.open(“outdata””);
    outdata << name << " " << age;
    outdata.close();

    • Matt on October 14, 2015 at 9:51 pm

      The code has an error. Please use the code below for the correct program.

      for some reason I Didn’t fix all that was intended, this is the working code, sorry everyone. Happy Programming

      string name;
      int age;

      cin >> name >> age;
      outdata.open(“outdata”);
      outdata << name << " " << age;
      outdata.close();

Leave a Comment

You must be logged in to post a comment.