int main( void)
{
FILE *fp_sour;
FILE *fp_dest;
char *buf;
int buf_size;
buf_size = 1024;
if ( fp_sour = fopen( "./main.c", "r"))
{
if ( fp_dest = fopen( "./backup.c", "w"))
{
buf = malloc( buf_size+5);
while( fgets( buf, buf_size, fp_sour))
fputs( buf, fp_dest);
free( buf);
fclose( fp_dest);
}
fclose( fp_sour);
}
return 0;
}
위에 보면 malloc 할때
버퍼사이즈 +5 하는데
+5하는 이유가 머졍?
댓글 0