[問題] C語言 使用 sscanf()函數
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
VC++
額外使用到的函數庫(Library Used): (Ex: OpenGL, ...)
無
問題(Question):
我這幾天需要讀出一個資料夾的檔案名
我已經順利可以讀出了
例如:
a.txt
b.txt
c.txt
但 我只需要 a 這個字串
我試著使用 sscanf("a.txt","%s.bmp",str);
結果 : str = a.txt
我上網查一下 : 似乎必須使用 %[^] 這類判斷式
我把程式 改成 sscanf("a.txt","%[^.]",str);
結果 : str = a
這樣看似解決我的問題了
但 如果檔名是 1.a.txt
sscanf("1.a.txt","%[^.]",str);
結果 : str = 1
他似乎讀到第一個 '.' 就停止了
如果我想要完成我的需求
我的判別式 要怎麼寫呢
查了好久 還是解不出來
還麻煩各位大大給予指導
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 125.230.10.200
→
08/29 21:43, , 1F
08/29 21:43, 1F
→
08/29 21:43, , 2F
08/29 21:43, 2F
→
08/29 21:45, , 3F
08/29 21:45, 3F
→
08/29 21:46, , 4F
08/29 21:46, 4F
→
08/29 21:46, , 5F
08/29 21:46, 5F
→
08/29 21:47, , 6F
08/29 21:47, 6F
→
08/29 21:48, , 7F
08/29 21:48, 7F
→
08/29 21:58, , 8F
08/29 21:58, 8F
→
08/29 22:04, , 9F
08/29 22:04, 9F
→
08/29 22:07, , 10F
08/29 22:07, 10F
推
08/29 22:26, , 11F
08/29 22:26, 11F
→
08/29 22:47, , 12F
08/29 22:47, 12F
→
08/29 22:48, , 13F
08/29 22:48, 13F
推
08/29 23:36, , 14F
08/29 23:36, 14F
→
08/29 23:36, , 15F
08/29 23:36, 15F