Fich: almacenar texto. fgets, fputs

14 fich almacenar texto fgets fputs.html
/* Manejo de ficheros: fopen, fgets, fputs, fclose */
#include <stdio.h>


int main(int argc, const char * argv[]) {
 FILE *fichero;
 char texto[1000];
 fichero=fopen("datos.txt", "w+");
 printf("introduzca el texto que quiera almacenar en el archivo: \n");
 fgets(texto, 1000, stdin); //lee del teclado
 fputs(texto, fichero); // escribir en el fichero
 fclose(fichero);
 return 0;
}


No hay comentarios:

Publicar un comentario