Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Гришин Tmsu 2
- Ардашев Tmsu 3
- Котов Smdf 4
- Евсеев Smdf 3
- Новиков LLsd 2
- #include <iostream>
- #include <fstream>
- #include <cstring>
- #include <string>
- using namespace std;
- struct data_box
- {
- char second_name[50];
- char subject_name[50];
- int subject_val;
- };
- int main() {
- setlocale(LC_ALL, "Russian");
- struct data_box data_arr[4];
- char data_second_name[50], data_subject_name[50];
- int data_subject_val;
- int i,j = 0;
- std::ifstream data_file;
- std::string str;
- data_file.open("data.txt");
- while (data_file >> data_second_name >> data_subject_name >> data_subject_val) {
- strcpy(data_arr[j].second_name, data_second_name);
- strcpy(data_arr[j].subject_name, data_subject_name);
- data_arr[j].subject_val = data_subject_val;
- j++;
- }
- for (i = 0; i < (sizeof(data_arr)/sizeof(data_arr[0])); i++){
- cout << data_arr[i].second_name;
- }
- data_file.close();
- return 0;
- }
- ГришинАрдашевКотовЕвсеев
- Process returned -1073741819 (0xC0000005) execution time : 9.177 s
- Press any key to continue.
- #include <iostream>
- #include <fstream>
- #include <string>
- #include <vector>
- using namespace std;
- struct data_box
- {
- string second_name;
- string subject_name;
- int subject_val;
- };
- int main()
- {
- setlocale(LC_ALL, "Russian");
- vector<data_box> data_arr;
- ifstream data_file("data.txt");
- if (!data_file.is_open()) exit(EXIT_FAILURE);
- data_box tmp;
- while(data_file >> tmp.second_name >> tmp.subject_name >> tmp.subject_val) {
- data_arr.push_back(tmp);
- }
- for (int i = 0; i < data_arr.size(); i++) cout << data_arr[i].second_name << endl;
- return 0;
- }
- int main()
- {
- setlocale(LC_ALL, "Russian");
- vector<data_box> data_arr;
- ifstream data_file("data.txt");
- if (!data_file) exit(EXIT_FAILURE);
- data_box tmp;
- while(data_file >> tmp.second_name >> tmp.subject_name >> tmp.subject_val) {
- data_arr.push_back(move(tmp));
- }
- for (const auto &data: data_arr) cout << data.second_name << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement