我想strcat一個路徑名傳遞給fopen以在while循環中創建多個文件名。strcat後恢復爲空
char path[30]="";
while(!feof(stdin))
{
strncat(path,folder,8);
strcat(path,filename);
strncat(path,ext,4);
printf("file path:%s\n",path);
File[n] = fopen(path,"a");
path=0;
}
如何返回空char數組的路徑,以便我可以再次連接? 還是有更好的方法來做到這一點?
分段錯誤,因爲路徑將保持原來的字符串時,它循環之後。 – user2130765 2013-03-04 07:10:22