[問題] string & char 沒有可接受的轉換?
程式碼(Code):(請善用置底文網頁, 記得排版)
#include <iostream>
using namespace std;
char store[10];
struct a{
string iWanttostoreit;
};
typedef struct a TreeNode;
typedef TreeNode *TreeNodePtr;
int main()
{
TreeNodePtr treePtr = new TreeNode;
cin >> store;
treePtr->iWanttostoreit = store;
cout << treePtr->iWanttostoreit;
}
Q2.(已解決)
他寫說找不到適當的轉換 可是他不是字串嗎?
為什麼不能直接輸出呢? james732:nclude <string>
Q1.(已解決)
想請問一下,字串沒有辦法直接用上述方式存進去嗎?
他會顯示存入錯誤@ @ 謝謝各位!
->此題解法請參考 james732 http://pastie.org/1855925
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.246.179
→
05/02 15:46, , 1F
05/02 15:46, 1F
→
05/02 16:08, , 2F
05/02 16:08, 2F
→
05/02 16:18, , 3F
05/02 16:18, 3F
→
05/02 16:23, , 4F
05/02 16:23, 4F
→
05/02 16:28, , 5F
05/02 16:28, 5F
→
05/02 16:56, , 6F
05/02 16:56, 6F
→
05/02 17:08, , 7F
05/02 17:08, 7F
※ 編輯: kimgtob 來自: 140.116.191.88 (05/02 17:38)
→
05/02 17:42, , 8F
05/02 17:42, 8F
→
05/02 17:44, , 9F
05/02 17:44, 9F
※ 編輯: kimgtob 來自: 140.116.191.88 (05/02 17:46)
→
05/02 17:47, , 10F
05/02 17:47, 10F
→
05/02 17:48, , 11F
05/02 17:48, 11F
→
05/02 17:48, , 12F
05/02 17:48, 12F
→
05/02 17:48, , 13F
05/02 17:48, 13F
C_and_CPP 近期熱門文章
PTT數位生活區 即時熱門文章