'Why am I not able to get each data of these?
I'd like to get each data of Name, Subject, Grade but I'm not able to get data of Name because getting data of Name have been ignore and it has been gone on to getting data of Subject.
Here's my source code
#include <iostream>
#include <string>
using namespace std;
int TheNumofStd = 0;
struct Subject
{
char *Subname;
int Credit;
char *Grade;
float GPA;
};
struct Student
{
char *StdName;
int StdID;
Subject* Sub;
int SubNum;
float AveGPA;
};
int main()
{
getStdName();
getSubjectName();
getGrade();
return 0;
}
string getStdName()
{
string name;
cout << "Name : ";
getline(cin, name);
return name;
}
string getSubjectName()
{
string subname;
cout << "Subject : ";
getline(cin, subname);
return subname;
}
string getGrade()
{
string grade;
cout << "Grade(A+ ~ F) : ";
getline(cin, grade);
cout << "\n\n";
return grade;
}
The result I want to print is getting each data of Name, Subject and Grade
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
