-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFlamme2.cpp
56 lines (47 loc) · 1.62 KB
/
Flamme2.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>
using namespace std;
const int x_resolution = 512;
const int y_resolution = 512;
//anlegen der Matrix
double input_data [x_resolution][y_resolution];
// Speicherort der Datei
string filePath = "C:\\Users\\nilsf\\Dokumente\\KIT\\3. Semester\\Informatik Praktikum\\FlammenbilderRohdaten\\Hauptflamme.txt";
void importFromFile (string filePath) {
string curInputVal;
// Datei einlesen
ifstream Datei(filePath);
//Prüfen ob Datei offen ist
if (Datei.is_open ()) {
cout << "Startet das einlesen der Datei." << endl;
string curInputVal;
int i = 0;
int j = 0;
// Speichern der Werte in einer 512 x 512
while (getline(Datei, curInputVal,' ')) {
if(!curInputVal.empty()){ // Prüfen ob curInputVal leer zugewiesen würde
double number = atof(curInputVal.c_str()); // string in double convertieren
input_data [i][j] = number;
if (j < x_resolution -1) { //Abspeichern in der Matrix
j++;
}
else {
i++;
j = 0;
}
}
}
}
else {
cout << "Fehler beim oeffnen der Datei" << endl;
}
// Datei wird geschlossen
Datei.close();
}
int main () {
importFromFile(filePath);
printf ("%f", input_data[511][511]); // bei cout werden die Nachkommastellen gekürzt
return 0;
}