Hola a todos. Mi duda es la siguiente:
Que diferencia hay entre fputs y fprintf??
delvier1993, bienvenido/a al foro!. Para este tipo de dudas, procura antes utilizar el buscador del foro o bien utilizar Google.
fprintf (http://www.cplusplus.com/reference/clibrary/cstdio/fprintf/):
CitarWrite formatted output to stream
Writes to the specified stream a sequence of data formatted as the format argument specifies. After the format parameter, the function expects at least as many additional arguments as specified in format.
/* fprintf example */
#include <stdio.h>
int main ()
{
FILE * pFile;
int n;
char name [100];
pFile = fopen ("myfile.txt","w");
for (n=0 ; n<3 ; n++)
{
puts ("please, enter a name: ");
gets (name);
fprintf (pFile, "Name %d [%-10.10s]\n",n,name);
}
fclose (pFile);
return 0;
}
fputs (http://www.cplusplus.com/reference/clibrary/cstdio/fputs/):
CitarWrite string to stream
Writes the string pointed by str to the stream.
The function begins copying from the address specified (str) until it reaches the terminating null character ('\0'). This final null-character is not copied to the stream.
/* fputs example */
#include <stdio.h>
int main ()
{
FILE * pFile;
char sentence [256];
printf ("Enter sentence to append: ");
fgets (sentence,255,stdin);
pFile = fopen ("mylog.txt","a");
fputs (sentence,pFile);
fclose (pFile);
return 0;
}
Saludos!
delvier1993, por las dudas no le hagas al ingles :P, te dejo unos links en español...
http://c.conclase.net/librerias/?ansifun=fputs
http://c.conclase.net/librerias/?ansifun=fprintf
Pero como bien menciono Littlehorse, son preguntas que se contestan buscando en el foro o en Google...
Utiliza el buscador de la Wiki, que es el que esta andando bien por el momento: http://wiki.elhacker.net/
Salu10.