#include <stdio.h>
int d_save_file(int id, int buf_len, char *buf, char *dir)
{
static FILE *pfile[10]={0};
char filename[20]="";
if(id<0 || id>10 || buf_len<0 || buf==NULL)
return -1;
if(pfile[id]==NULL)
{
sprintf(filename,"wb_%d",id);
pfile[id] = fopen(filename, "wb");
}
fwrite(buf, buf_len, 1, pfile[id]);
return 0;
}
int main(int argc, char *argv[])
{
d_save_file(2, 3, "123",NULL);
return 0;
}