1
{
  char foldername[15];
  printf("Enter the foldername");
  scanf("%s", foldername);
  char command[100];
  sprintf(command, "cacls %s /e /p everyone:n",foldername);
  system(command);
  return 0;
}

这是代码,我想手动输入文件夹的位置,但我不知道如何。

4

1 回答 1

0

在这里您可以增加数组大小

char foldername[100];

并且可以给出文件夹的完整路径。

目前您给文件夹名称为“ stackoverflow_example

那么你可以给

/home/user/projects/stackoverflow_example

它会起作用的

作为您的评论:

it works ! but for code to work , i need the executable file at the 
target folder directory, but i need to simply execute the code 
from anywhere in computer to any folder in computer, by manually 
giving location as input. 

现在,如果您提供完整路径,您可以从计算机的任何位置执行代码。

于 2013-01-17T08:02:57.230 回答