Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <conio.h>
- using namespace std;
- const int ratingSize = 5;
- struct Students
- {
- char name[20];
- int groupId;
- int rating[ratingSize];
- };
- int main()
- {
- FILE *fileRead;
- char* filePath = new char[];
- cout << "Filepath: ";
- gets(filePath);
- while(!(fileRead = fopen(filePath, "r")))
- {
- cout << "Wrong filepath, try again ";
- cout << endl;
- cout << "Filepath: ";
- gets(filePath);
- }
- int sizeGroup = 4;
- const int sizeBuffer = 1000;
- char buffer[sizeBuffer];
- int temp;
- Students* group = new Students[sizeGroup];
- for (int i = 0; i < sizeGroup; i++)
- {
- temp = 25;
- fgets(buffer, sizeBuffer, fileRead);
- strncpy(group[i].name, buffer, 19);
- group[i].name[19] = '\0';
- group[i].groupId = atoi(&buffer[20]);
- cout << endl << "Name: " << group[i].name << endl;
- cout << "Group Id: " << group[i].groupId << endl;
- cout << "Rating: ";
- for (int j = 0; j < ratingSize; j++)
- {
- group[i].rating[j] = atoi(&buffer[temp]);
- temp+=5;
- cout << group[i].rating[j] << " ";
- }
- cout << endl;
- }
- fclose(fileRead);
- _getch();
- return 0;
- }
- //Ivanov I.I. 45 5 4 3 4 4
- //Petrov P.P. 15 3 3 4 3 5
- //Sidorov S.S. 4 5 5 4 5 4
- //Durov D.D. 20 4 3 4 3 4
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement