#include <stdio.h> int fputs(const char *string, FILE *file);
Esta función escribe todos los caracteres de string (excepto el carácter nulo) en el fichero cuyo descriptor es file. El cursor del fichero avanza los caracteres escritos.
Un número no negativo en caso de éxito, EOF en caso de error.
ANSI, POSIX
La función copiaFicheroTexto copia un fichero texto en otro. La lectura y escritura se hace línea a línea.
#include <stdio.h> #include <stdlib.h> #define MAXLINEA 1024 int copiaFicheroTexto(const char *origen, const char *destino){ FILE *fo, *fd; char linea[MAXLINEA]; if((fo=fopen(origen,"rt")) == NULL) return -1; if((fd=fopen(destino,"wt+")) == NULL){ fclose(fo); /* Se cierra el fichero abierto */ return -2; } while( fgets(linea,MAXLINEA,fo) != NULL) if(fputs(linea,fd) == EOF){ fclose(fo); fclose(fd); return -3; } /* Se cierran los ficheros */ fclose(fo); fclose(fd); return 0; }