#include <fstream>
#include <iostream>
using namespace std;
int main()
{
ofstream file("datos.txt");//salida
file << "Juan Perez" << endl; // Guardar en el archivo
file.close();//cerrar
ifstream input("datos.txt");//entrada
string name;
input >> name;
cout << "Nombre leído: " << name << endl; // Leer desde el archivo
input.close();
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: