-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharchivos.cpp
47 lines (35 loc) · 944 Bytes
/
archivos.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
#include <iostream>
#include <fstream>
using namespace std;
int main()
{
/*ofstream myFile("GameData.txt");
string playerName = "";
if(myFile.is_open()){
myFile << "Hola Linda!" << endl;
myFile << "mi nombre es: " << endl;
cout << "Introduce el nombre de tu heroe:" << endl;
cin >> playerName;
myFile << playerName;
}
myFile.close();
*/
ifstream myFileRead("GameData.txt");
string line;
string nombreHeroe = "";
int renglon = 0;
if(myFileRead.is_open()){
while (getline(myFileRead, line))
{
if(renglon == 2){
nombreHeroe = line;
}
renglon++;
}
}else{
cout << "No logre abrir mi archivo, checar el antivirus!!" << endl;
}
cout << "Bienvenida a tu aventura: " << endl;
cout << nombreHeroe << endl;
return 0;
}