Fich: Crear y agregar mas texto, fputc, "at"

08 crear y agregar mas texto.html
#include <stdio.h>
#include <stdlib.h>

FILE *fd;

int main(){
	int c;
	char direccion[] = "C:\\Users\\crearyagregarmas.txt";
	
	fd = fopen(direccion, "at"); // at = add text
	
	if(fd==NULL){
		printf("Error. No se pudo crear el archivo.\n");
	}
	printf("Ingresa tu texto: \n");
	while((c=getchar())!= EOF){
		fputc(c,fd);
	}
	fclose(fd);
	
	system("pause");
	return 0;
}

No hay comentarios:

Publicar un comentario