
leer escribir datos en archivos txt en c++
Publicado por Nelmer (2 intervenciones) el 02/11/2015 22:33:45
No puedo escribir datos de tipo int en un archivo txt, alguien podria ayudarme este es codigo que tengo
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
#include <iostream>
using namespace std;
int main(int argc, char** argv) {
char nombre[40];
int edad;
FILE*archivo=fopen("file.txt", "w+");
cout<<"Ingrese un nombre: ";
cin>>nombre;
fprintf(archivo,nombre);
cout<<"Ingrese su edad: ";
cin>>edad;
fprintf(archivo,edad);
return 0;
}
Valora esta pregunta


0