Like the title, I can't receive it continuously. At the first input, it's very normal. But when I press Enter to go to next input, it turned out like this:
Here is my source code:
#include <iostream>
#include <fstream>
#include <string>
#include <stddef.h>
#include <stdint.h>
using namespace std;
typedef struct SV {
char name[50];
uint8_t age;
char gender;
float average;
float math;
float literature;
float chemical;
float physical;
float biological;
} SV_Info;
class SV_Manager {
private:
SV_Info *sv_info;
public:
/**
* @brief Constructor SV_Manager, nếu không truyền
* tham số là số sinh viên tối đa hiện tại thì sẽ
* mặc định là 100 sinh viên
*
*/
SV_Manager() {
sv_info = new SV_Info[100];
}
SV_Manager(size_t max_sv) {
sv_info = new SV_Info[max_sv];
}
void Add_SV() {
cout << "Nhap ten cua sinh vien (toi da 50 ki tu): ";
char name[50];
cin >> name;
cout << "Nhap tuoi cua sinh vien: ";
uint8_t age;
cin >> age;
cout << "Nhap gioi tinh cua sinh vien: ";
char gender[10];
cin >> gender;
cout << "Nhap diem Ngu Van cua sinh vien: ";
float literature;
cin >> literature;
cout << "Nhap diem Toan cua sinh vien: ";
float math;
cin >> math;
cout << "Nhap diem Ly cua sinh vien: ";
float physical;
cin >> physical;
cout << "Nhap diem Sinh cua sinh vien: ";
float biological;
cin >> biological;
}
};
int main(int argc, char **argv) {
std::cout << "Hello World!" << std::endl;
SV_Manager manager;
manager.Add_SV();
system("pause");
}
I'm using MinGW GCC 6.3.0 to compile this. I have tried all solutions on Internet but it's useless. Can anyone help me?