簡體   English   中英

如何在C中將此文件夾鎖定代碼作為輸入提供給文件夾位置?

[英]How to give Folder location on as input on this folder lock code in C?

{
  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;
}

這是代碼,我想手動輸入文件夾的位置,但是我不知道如何。

在這里您可以增加數組大小

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. 

現在,如果您給出完整路徑,則可以從計算機中的任何位置執行代碼。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM