(C++學習)關於CString的一些疑問

來源:互聯網
上載者:User

標籤:代碼   解析   學習   模板   資料   指定   clu   turn   span   

 1 #include <iostream> 2 #include <string> 3 #include <afx.h> 4 #include <vector> 5  6 using std::vector; 7 using std::cout; 8 using std::endl; 9 10 int  main()11 {12     CString strText ="";13     int testArray[] ={1,2,3,4,5,6};14     vector<int> vecNum(testArray,testArray+6); //vector --可以指定資料類型的容器,通常用於未確定大小的數組中15     cout<<vecNum.size()<<endl; // 輸出616     for (int i = 0; i < vecNum.size(); i++)17     {18         cout << vecNum[i] <<endl; //輸出:1、2、3、4、5、619 20         // 將CString類型賦值21         // _T("%d") 是c++中一個類似解析模板的東西, %d 代表 int 類型, long 類型就要換成 %ld22         strText.Format(_T("%d"), vecNum[i]); 23 24         //輸出:1、2、3、4、5、625         cout << strText<<endl; 26     }27     cout<<vecNum.size()<<endl; // 輸出628     return 0;
29 30 31 }

上述代碼中:

cout << strText<<endl; 

出現問題了,理論上也應該輸出:1、2、3、4、5、6

但是輸出的是一個類似 004D9540 的數值,這個數字是隨時變得,但是6次輸出都是一模一樣

問了下公司的C++,有位說是記憶體位址,但是網上找了一些方法都不能進行解析。

如果哪位大佬知道,私信留言都可以。

(C++學習)關於CString的一些疑問

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.