[問題] InttoString 問題
開發平台(Platform): Linux ubuntu
問題(Question):
code:
-----------------
char i_str[256],j_str[256];
sprintf(i_str,"%d",i);
sprintf(j_str,"%d",j);
str+='('+i_str+','+j_str+','+combine[i]+','+combine[j]+')'+',';
cout<<str<<endl;
--------------------
簡單的int to string
Error Code:|332|error: invalid operands of types ‘char*’ and
‘char [256]’ to binary ‘operator+’|
關鍵應該是在i_str和j_str
i , j ,型態皆為int
combine[i],combine[j] 為vector<string>
預期的正確結果(Expected Output):
(1,2,source,target),
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 163.22.21.92
※ 文章網址: http://www.ptt.cc/bbs/C_and_CPP/M.1412580127.A.43E.html
→
10/06 16:59, , 1F
10/06 16:59, 1F
推
10/06 17:54, , 2F
10/06 17:54, 2F
→
10/06 17:59, , 3F
10/06 17:59, 3F
→
10/06 20:03, , 4F
10/06 20:03, 4F
→
10/06 21:11, , 5F
10/06 21:11, 5F
→
10/06 21:14, , 6F
10/06 21:14, 6F
→
10/06 21:15, , 7F
10/06 21:15, 7F