Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 505505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:36:20+00:00 2026-05-13T06:36:20+00:00

So my assignment is to create multiple classes for a Person, Name, ID #,

  • 0

So my assignment is to create multiple classes for a Person, Name, ID #, Address, and Phone #.

Name makes up: First, Middle, and Last name.
ID # makes up: 9 digits.
Address makes up: street, city, state, and 5 digit zip code.
Phone # makes up: 3 digit area code and 7 digit number.
Person makes up: a full Name (First, Middle, Last), an Address, a Phone # (area code, and number), and a ID # (9 digit number).

I have accomplished all of this. My problem is we are also supposed to make a menu, to specify how many people the user wishes to type in, where they want to save the file, if they want to read or write to a file specified by the user, and being able to sort the people by name (last, first, or middle) or by ID #, and save the sorted list to a user specified file.

I have all the code written, but my write function is not working for some reason. What happens is I run the program, the menu I created pops up. I select ‘1’ enter the file, then the menu pops up again, and I select ‘2’ to make sure it cant read since there is nothing in the specific file I am testing with. Next, I select ‘3’ to write People to the user specified file. It prompts me for how many People I want to enter and I enter a number (2). Then the prompt for typing in the first name pops up and I get some error saying “an unhandled win32 exception occured” in my project .exe…

Here is my code:

//global variables
char filename[256];
fstream file2 (filename);

int r;
Person * stuArrPtr=new Person[r];

int w;
Person * stuArrPtr2=new Person[w];

//global functions
void WriteUserFile () {
//write as many ppl as specified to a file...
// int w;
 cout << "How many students would you like to enter?: ";
 cin  >> w;

// Person * stuArrPtr2=new Person[w];
 if (!file2.is_open ()) {
  cout << "File did not open" << endl;
  file2.clear ();
  file2.open (filename, ios_base::out);
  file2.close ();
  file2.open (filename, ios_base::out | ios_base::in);

 }
 else {
  for (int i = 0; i < w/*!file2.eof ()*/; i++) {
   stuArrPtr2[i].InputPerson();
   if (strcmp(stuArrPtr2[i].PersonNam.GetFirst(), "EOF") != 0)
    stuArrPtr2[i].Display (file2);
  }
 }
 cout << endl;
// delete [] stuArrPtr2;
}

void Menu () {
 int option;
 do {
  //display menu
  cout << " Type '1' - to open a file for reading or writing" << endl << endl;
  cout << " Type '2' - to read from the file you specified in '1'" << endl << endl;
  cout << " Type '3' - to write from the file you specified in '1'" << endl << endl;
  cout << " Type '4' - sort students by last name" << endl << endl;
  cout << " Type '5' - sort students by first name" << endl << endl;
  cout << " Type '6' - sort students by middle name" << endl << endl;
  cout << " Type '7' - sort students by ID number" << endl << endl;
  cout << " Type '8' - exit" << endl << endl;
//  cout << " Enter appropriate number here: [ ]\b\b";
  cout << " Enter appropriate number here: ";
  cin >> option;

  switch(option) {
   case 1:
    cout << "you entered option 1" << endl;
    OpenUserFile ();
    break;
   case 2:
    cout << "you entered option 2" << endl;
    ReadUserFile ();
    break;
   case 3:
    cout << "you entered option 3" << endl;
    WriteUserFile ();
    break;
   case 4:
    cout << "you entered option 4" << endl;
    SortLastName ();
    break;
   case 5:
    cout << "you entered option 5" << endl;
    SortFirstName ();
    break;
   case 6:
    cout << "you entered option 6" << endl;
    SortMiddleName ();
    break;
   case 7:
    cout << "you entered option 7" << endl;
    SortIDNumber ();
    break;
   case 8:
    cout << "you entered option 8" << endl; //exit
    delete [] stuArrPtr;
    delete [] stuArrPtr2;
    break;
   default:
    cout << "you screwed up, no big deal, just try again!" << endl;
  } //end switch
  //if (option == 6) {
  // break;
  //}
 } while (option != 8);
// system("pause"); 
}

void main () {
Menu ();
}
/////////////////END OF CODE///////

Sorry the code is so long, and any help is very, very much appreciated!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:36:21+00:00Added an answer on May 13, 2026 at 6:36 am

    the problem with your code are the first few lines.

    int w;
    Person * stuArrPtr2=new Person[w];
    

    At program startup w is most probably initialized with 0. So you create an array of zero Persons.
    The moment you call stuArrPtr2[i].InputPerson() which should be stuArrPtr2[i]->InputPerson() by the way, you try to access a member function of an non existing object.

    What you will have to do is create new Person objects depending on the number you just entered like stuArrPtr2 = new Person[w] within the function WriteUserFile().

    Cheers
    Holger

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am working on an assignment and have to create two classes, one represents
I have an assignment to create a GUI using MATLAB GUIDE and am having
I have an assignment to create a secure communication between 2 people with a
My assignment is to create a simple graph that has both Nodes and Edges.
I'm using super-simple synchronous C# Sockets for an assignment. The assignment is to create
Hello I'm new to ontologies, my assignment is to create an ontology using Protege
So basically the assignment was we had to create a doubly linked list that's
For this assignment I had to create my own string class. I initially wrote
For a school assignment I have to create a C++ program that will create
The assignment in the Big Nerd Ranch Guide says: Silver Challenge: Another initializer Create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.