2014-01-08 66 views
0

我試圖通過使用cmd命令「dir」打印目錄,但系統功能打印訪問被拒絕,即使我作爲管理員運行該程序。c - 系統功能打印訪問被拒絕

char line[256]; 
char directory[256]; 
char temp[512]="dir "; 
int type; 
FILE* file; 
puts("enter directory"); 

gets(directory); 


strcat(temp,directory); 
strcat(temp," >> d:\temp.txt"); 
system(temp); 


file=fopen("d:\temp.txt","r"); 

回答

1

d:\temp.txt變化d:\\temp.txt

"d:\temp.txt""d:\\temp.txt"

\是字符串字面轉義序列。