【发布时间】:2015-08-14 09:10:02
【问题描述】:
我想创建一个在提供的名称后添加特定扩展名的文件。
我创建了这段代码:
void create_file(char name[],char user[],char date[]){
FILE* fichier=NULL;
fichier=fopen(strcat(name,".txt"),"a+");
fprintf(fichier,"user: %s connected at : %s \n",user,date);
fclose(fichier);
}
但它不起作用。
【问题讨论】:
-
我想将 name 与 ".txt" 连接我没有得到好的解决方案。我尝试创建一个新字符串 char ch1[]=strcat(name,".txt") 我得到了一个错误。
-
@arrowman 你遇到了什么错误?
-
错误:初始化程序无法确定“ch1”的大小
-
我不得不说,请使用tour 并阅读How to Ask 以了解我们对这里问题的期望。