Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <string>
- using namespace std;
- int main() {
- string nombre;
- int edad;
- double salario;
- ofstream archivo("empleados.dat");
- if (!archivo.is_open()) {
- cout << "No se pudo abrir el archivo" << endl;
- return -1;
- } do {
- cout << "Ingrese el nombre: ";
- getline(cin, nombre);
- if (nombre != "") {
- cout << "Ingrese la edad: ";
- cin >> edad;
- cin.ignore();
- cout << "ingrese el salario: ";
- cin >> salario;
- cin.ignore();
- cout << endl;
- //cin.get();
- archivo << nombre << "\t" << edad << "\t" << salario << "\t" << endl;
- }
- } while (nombre != "");
- archivo.close();
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement