[英]passing multiple arguments that are file names from multiple txt files to a c program ran in linux terminal
[英]input arguments from txt files in C programs
我做了一個可以接受多個參數的程序。 不幸的是,當涉及到大數字時,手動輸入它們是非常不切實際的。 所以問題是。 我可以使用包含所有參數的.txt文件並在啟動程序時從文件中加載它們嗎? 我將不勝感激。
如果鍵入數據(手動輸入),請在運行程序時考慮替換輸入流
Program <input.txt
在這種情況下,input.txt文件必須包含您之前手動鍵入的所有數據。 無需重寫和重建代碼。
編輯:
要添加命令行參數,請從腳本中運行程序,例如
# this is runprog script
Program arg1 arg2 arg3
當您運行runprog
它將運行Program
並且arg1
, arg2
和arg3
變為argv(自動計算argc)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.