[問題] 取檔案內容 再把內容當成檔名開檔

看板C_and_CPP作者 (任性夠了沒?)時間13年前 (2011/07/06 21:16), 編輯推噓0(002)
留言2則, 2人參與, 最新討論串1/1
開發平台(Platform): LINUX 額外使用到的函數庫(Library Used): 無... 問題(Question):從一個檔案中把內容撈出來 當做檔名再開檔卻開檔失敗 餵入的資料(Input): /mnt/memcached/failover_ip 預期的正確結果(Expected Output):應該不會印出 open failed 訊息 錯誤結果(Wrong Output): 會印出 Line length:15 incre : 14 failover ip : 192.168.39.155 failover count : 15 /mnt/memcached/192.168.39.155_11211_exist file length: 42 open failed 程式碼(Code): http://pastie.org/2172221 補充說明(Supplement): 如果將 sprintf(exits_file,"/mnt/memcached/%s_%s_exist",failover_client,client_tcp); 替換成 sprintf(exits_file,"/mnt/memcached/192.168.39.105_%s_exist",client_tcp); 就可以順利開檔 /mnt/memcached/failover_ip檔內容是 192.168.39.155 請各位懂的大大幫忙解一下 感恩Orz -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 58.115.19.89 ※ 編輯: smallma009 來自: 58.115.19.89 (07/06 21:18)

07/06 21:25, , 1F
failover_client末尾記得補0
07/06 21:25, 1F

07/06 21:30, , 2F
是再多寫入一個'\0'嗎? 感恩~
07/06 21:30, 2F
文章代碼(AID): #1E560gnB (C_and_CPP)