※ 引述《Upsha (Marin hardtail好棒)》之銘言:
: ※ 引述《ugoc (歷史都不歷史了)》之銘言:
: : 或者把string轉成char[]型態?
: title q, no way
: string strofcpp;
: cin >> strofcpp;
: const char strofc = new char;
: strofc = strofcpp.c_str();
: 我覺得怪怪的啦 但是可以用就是了
: 我無法理解為啥米不能用const char*替char*設初值
: but anyway it works now.
不行也
根據我多次的錯誤和debug之後
我發現這樣會對
const char *storechar;
//這裡要加const才會和string的定義相同
string instr;
cin >> instr;
storechar = instr.c_str();
//but我不是很了解為什麼。試出來的
--
※ 發信站: 批踢踢實業坊(ptt.csie.ntu.edu.tw)
◆ From: 210.85.118.7