将writelogs的参数(logname除外)连接起来,写成一条日志,我的程序写错了,帮帮忙看下
/*
实现功能:将writelogs的参数(logname除外)连接起来,写成一条日志
*/
# include <stdio.h>
# include <string.h>
int writelogs(char logname[],int errcode,int errrate,int suberrcode,unsigned char *msg);
int main(void)
{
writelogs('a',0x111,0x1,0x1111,'hello,it is a test1');
writelogs('b',0x222,0x1,0x3333,'hello,it is a test2');
return 0;
}
int writelogs(char logname[],int errcode,int errrate,int suberrcode,unsigned char *msg)
{
FILE *fp;
unsigned char temp1,temp2,temp3,temp4;
temp1=strcat(errcode,errrate);
temp2=strcat(temp1,suberrcode);
temp3=strcat(temp2," ");
temp4=strcat(temp2,msg);
/******mkfile-start*******/
if((fp=fopen("logname[]","a"))==NULL)
{
printf("error");
exit(0);
}
/******mkfile-over*******/
/******writelog-start*******/
gets(temp4);
strcat(temp4,"\n");/*add a newline*/
fputs(temp4,fp);
/******writelog-over*******/
fclose(fp);
return 0;
}
==========
我急用,请帮帮忙:)