Topic: HELP ME! I DON'T UNDERSTAND (pt. II)!!!!
Author: gmanzano@dino.conicit.ve (Gregorio Manzano)
Date: 1995/07/13 Raw View
Don't pay attention to my last article. It had a sintax mistake
Good Morning People!!
Actually, i'm editing a C program on my UNIX system that
modifies the user's record. After making the modifications, the program
saves these ones in a new file (datos_usuarios2 - opened in "w" mode); the
source file is called "datos_usuarios", opened in "r" mode. The problem is
that when the program tries to writes the new data on "datos_usuarios" (the
source file) it failures!!! It doesn't record any data!! I mean, when i
make a "ls -la", appears the source file with 0 bytes!!!!
The program makes this as follows:
system("mv datos_usuarios datos_usuarios.respaldo");
if((from=fopen("datos_usuarios2", "r")) == NULL)
{
perror("datos_usuarios2"); exit(0);
}
if((to=fopen("datos_usuarios","w")) == NULL)
{
perror("datos_usuarios"); exit(0);
}
while((n=fread(buf, sizeof(char), BUFSIZ, from)) > 0)
fwrite(buf, sizeof(char), n, to);
fclose(from, to);
PLEASE, IF U HAVE ANY ANSWER E-MAIL ME (gmanzano@dino.conicit.ve) RIGHT NOW!
THANKS IN ADVANCE... Greg!