Reputation: 11
I tried to print directory by using the cmd command "dir" but system function print Access is denied even when i run the program as adminstrator.
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");
Upvotes: 0
Views: 105
Reputation: 40145
d:\temp.txt
change to d:\\temp.txt
also "d:\temp.txt"
to "d:\\temp.txt"
\
is escape sequence in string literal.
Upvotes: 1