Enter name: a
Enter GPA: 3
Enter major: 2

Name: a
GPA: 3
Major: 2


Name: a
GPA: 3
Major: 2


Enter name: b
Enter GPA: 3
Enter Major: 2

Name: b
GPA: 3
Major: 2


Enter name: c
Enter GPA: 3
please enter major: 2

Enter name: d
Enter GPA: 3
please enter major: 2
c 3 2
d 3 2


this is after change in call of printstudents into main

new code

#include <iostream>

using namespace std;


struct Student
{
	char Name[30];
	float GPA;
	int Major;
};

//Function prototypes
Student* StudentData(Student* S);
void display(Student* S);
void ChangeData(Student* S);
void GetStudents(Student array[], int size);
void PrintStudents(Student array[], int size);

//Main information build
int main()
{
	//Declare two objects of type 'Student' as wanted in step #1
	Student* S1 = new Student;
	Student* S2 = new Student;
	//Step #6
	Student Students[2];
	
	//Pass this object into the function so it can be filled up with useful information as wanted in step #2
	S1 = StudentData(S2);
	//Display new and exciting information as specified in step #3
	display(S1);
	display(S2);	
	//Function call to change data in S2 as specified in step #4
	ChangeData(S2);
	//Displays ChangeData
	display(S2);
	//Step #7
	GetStudents(Students, 2);	
    //Step #9
	PrintStudents(Students, 2);
	
	return 0;
}


//Function Definitions Which Ask For User Input And Displays Them
Student* StudentData(Student* S)
{
	cout << "Enter name: ";
	cin >> S->Name;
	
	cout << "Enter GPA: ";
	cin >> S->GPA;
	
	cout << "Enter major: " ;
	cin >> S->Major;
	
	return S;
}

void display(Student* S)
{
	cout << "                " << endl;
    cout << "Name: " << S->Name  << endl;
    cout << "GPA: " << S->GPA   << endl;
    cout << "Major: " << S->Major << endl;
	cout << "                " << endl;
}

void ChangeData(Student* S)
{
	cout << "\nEnter name: ";
	cin >> S->Name;
	
	cout << "Enter GPA: ";
	cin >> S->GPA;
	
	cout << "Enter Major: " ;
	cin >> S->Major;
}
void GetStudents(Student array[], int size)
{
		
	for(int i=0; i<size; i++)
	{
		cin.ignore(1);
		cout << "            " << endl;
		cout << "Enter name: ";
		cin.getline(array[i].Name, 30);
		
		cout << "Enter GPA: ";
		cin >> array[i].GPA;
		
		cout << "please enter major: " ;
		cin >> array[i].Major;
		
		
	}
}
void PrintStudents(Student array[], int size)
{
	for(int i=0; i<size; i++)
    {
		cout << array[i].Name << ' ' << array[i].GPA << ' ' << array[i].Major << endl;
    }
}

line 41 is it right

i called the function in line 18

You did not call the function in line#18, you simply declared the function prototype.

You called the function at line#41.

line 41

i noticed after but its there just not sure if i declared it right

If it meets your project requirements and your compiler likes it, then it is declared right.

Also, try putting line #87 right before you call getline() at line #90.

is that it for number 9 after looking at it and reading i think it is

i think it does because it puts the two things in different lines

it is isnt it getline is at 90 and the other is at 87

I don't know what you are talking about in your previous 3 posts. They seem to be random thoughts. Perhaps you are experiencing dementia associated with hours of coding in c++.

like yours is

could be, but what i was trying to say is that the way i have it is the way you had it in the full code

You are a college student. This is not a proper and/or complete sentence:

it is isnt it getline is at 90 and the other is at 87

I will allow you one more opportunity to form a comprehensible question that resembles the English language.

isnt getline on line 90 and on line 87 is where ignore has been put, you told me to put the ignore before getline will this work

}
void GetStudents(Student array[], int size)
{
		
	for(int i=0; i<size; i++)
	{
		cin.ignore(1);
		cout << "            " << endl;
		cout << "Enter name: ";
		cin.getline(array[i].Name, 30);
		
		cout << "Enter GPA: ";
		cin >> array[i].GPA;
		
		cout << "please enter major: " ;
		cin >> array[i].Major;
		
		
	}

Yes... I think that works as long as there are no cin >> operations that take place between the ignore() and the getline() operation.

I believe the cin operation will leave an extraneous newline character in the input buffer that will thwart the efforts of getline() to read the buffer.

It's 2:00am... what am I doing here...

would this mean that 1 through 9 is done

Steps #1 through #9 are complete. Aside from the required error handling, the bulk of your project is complete.

Perhaps we could come up with a couple of functions to test user input for validity. If invalid, throw an error; catch error and respond appropriately.

But since I am tired as heck, I am about do like my programs and crash.

commented: You derserve rep for this monster thread. +11
commented: nuff said +1

thanks for your help ill be up until i can get this thing done we'll see how that goes

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.