[問題] 將string由fprintf印出
開發平台(Platform): (Ex: VC++, GCC, Linux, ...)
devC
問題(Question):
想要將string由fprintf印出
但似乎不可行(?)
如果還是想要用fprintf印出 有其他辦法可行嗎
錯誤結果(Wrong Output):
[Warning] cannot pass objects of non-POD type `struct std::string' through `
...'; call will abort at runtime
程式碼(Code):(請善用置底文網頁, 記得排版)
#include <iostream>
#include <string>
using namespace std;
int main()
{
FILE* file = fopen("output.txt","w");
string str = "stri";
fprintf(file,"%s",str);
//system("pause");
return 0;
}
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.243.66
→
01/13 13:17, , 1F
01/13 13:17, 1F
→
01/13 14:34, , 2F
01/13 14:34, 2F
→
01/13 14:36, , 3F
01/13 14:36, 3F
→
01/13 14:37, , 4F
01/13 14:37, 4F
→
01/13 14:37, , 5F
01/13 14:37, 5F
→
01/13 15:21, , 6F
01/13 15:21, 6F
→
01/13 15:22, , 7F
01/13 15:22, 7F
→
01/13 15:24, , 8F
01/13 15:24, 8F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章