Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void readMatrix(float **&matrix, int &n) {
- //odczytywanie z pliku
- ifstream file;
- string filename;
- cin >> filename;
- file.open(filename);
- if (file.good()) {
- string row;
- bool row1 = false;
- int i = 0;
- while (getline(file, row)) {
- if (!row1) {
- row1 = true;
- int amount = count(row.begin(), row.end(), ';');
- if (matrix != NULL)
- deleteMatrix(matrix, n);
- makeMatrix(matrix, amount);
- n = amount;
- }
- istringstream columns(row);
- string column;
- int j = 0;
- while (getline(columns, column, ';')) {
- matrix[i][j] = atof(column.c_str());
- j++;
- }
- i++;
- }
- file.close();
- }
- else cout << "Nie ma dostępu do pliku." << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement