将writelogs的参数(logname除外)连接起来,写成一条日志,我的程序写错了,帮帮忙看下

jourmen jourmen 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
/*
实现功能:将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;
}


==========
我急用,请帮帮忙:)
...全文
评论 6
收藏 已收藏
分享
返回顶部
jourmen
C语言 70,040 成员 243,237 内容