[問題] fopen的問題

看板C_and_CPP作者 (CS1DADA)時間13年前 (2011/06/07 20:09), 編輯推噓0(003)
留言3則, 2人參與, 最新討論串1/2 (看更多)
開發平台(Platform): (Ex: VC++, GCC, Linux, ...) linux 問題(Question): 程式要能夠以執行參數的方式指定要分析的檔案 餵入的資料(Input): test.out ./test/AAA.txt 預期的正確結果(Expected Output): 正確的開啟AAA.txt 程式碼(Code):(請善用置底文網頁, 記得排版) #include <stdio.h> char *GS; int main(char *argv[]){ GS=argv[1]; 想問說如果我已經把./test/AAA.txt存在GS中 如何利用GS使用fopen來開AAA.txt fopen("檔名","mode");檔名應該不能直接改成GS吧= = 還是有別的方法可以用? FILE *slPtr; if ((slPtr=fopen("AAA.txt","a+"))==NULL){ printf("file could not opened\n"); } else{ fprintf(slPtr,"successfully write\n"); } } -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.118.74.175

06/07 20:57, , 1F
你的意思是 fopen(GS , "a+") 這樣嗎?
06/07 20:57, 1F

06/07 21:03, , 2F
對 可以直接放進去嗎@@
06/07 21:03, 2F

06/07 21:22, , 3F
成功了 謝謝你
06/07 21:22, 3F
文章代碼(AID): #1DxXJsQz (C_and_CPP)
討論串 (同標題文章)
文章代碼(AID): #1DxXJsQz (C_and_CPP)