Everytime i run my program after i enter my first value for the number of students, i get the windows box that pops up and says studens.exe has encountered a problem and needs to close. Is this a problem with my cose of a computer problem? thanks

#include <iostream>  // allows the program to output data to the screen
#include <conio.h>
#include  <iomanip>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include "students.h" // gradebook class defintion


using std::cout; // program uses cout
using std::cin; // program uses cin
using std::endl; // program uses endl
using std::setprecision; // set numeric output precision
using std::fixed; // ensures that decimal point is displayed
using std::setw;
using std::string;
using std::vector;


void  students::displayMessage()
{
		
	cout << endl << "Welcome to the Student Scores Application." << endl << endl;
}
		

void students::getData()
{
	int num = 1;
	int num2 = 1;
	int num3 = 1;
	int numStudents = 0;
	vector<string> student_lastnames(numStudents);
	vector<string> student_firstnames(numStudents);
	vector<int> student_score(numStudents);
	
	cout <<"Enter number of students to enter: ";
	cin >> numStudents;
	
	for (int i = 0; i <= student_lastnames.size(); i++)
	{ 
            cout << "Student " << num <<" last name: "; 
            getline (cin, student_lastnames[i]);
		num++;
	}

	
	for (int j = 0; j <= student_firstnames.size(); j++)
	{ 
            cout << "Student " << num2 <<" first name: "; 
            getline (cin, student_firstnames[j]);
		num2++;
	}

	
	for (int k = 0; k <= student_score.size(); k++)
	{ 
            cout << "Student " << num3 <<" score: "; 
            cin >> student_score[k];
		num3++;
	}

            // sort them alphabetically
        sort (student_lastnames.begin(), student_lastnames.end());

	for (int l =0; l <= student_lastnames.size(); l++)
	{
			cout << student_lastnames[l] << "" << student_firstnames[l] << "" << student_score[l];
	}
	  
	
	
}

// function main begins program exectuion
int main() 
{
	students mystudent;
	
	mystudent.displayMessage();

	mystudent.getData();	
	
}
#include <iostream>  // allows the program to output data to the screen
#include <string>

// students class definition
class students
{
public:
	void getData(); // function to get first and last name and the students grade
	void displayMessage(); // displays welcome message

private:

};

Three key lines int numStudents = 0; vector<int> student_score(numStudents); cin >> numStudents; Now, how long is student_score really?

You get how many there is at the time you ask. It doesn't create a reference which tracks all future changes to numStudents.

Rearrange the order of statements so objects which depend on the size of some user input value are created AFTER that value is known.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.