• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

              C++博客 :: 首頁 :: 聯系 :: 聚合  :: 管理
              117 Posts :: 2 Stories :: 61 Comments :: 0 Trackbacks

            常用鏈接

            留言簿(8)

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            1、 將“字符串”轉化換為“整數”

                  1.1    轉換函數

                     字符串轉換成雙精度類型的函數有:atof(……)和_wtof(……)
                     轉換成整型的函數有:atoi(……)、_atoi64(……)、_wtoi(……)和_wtoi64(……)
                     轉換成長整型的函數有:atol(……)和_wtol(……)。

            函數的原型如下:

            double atof(
               
            const char *string
            );
            double _wtof(
               
            const wchar_t *string
            );
            int atoi(
               
            const char *string
            );
            _int64 _atoi64(
               
            const char *string
            );
            int _wtoi(
               
            const wchar_t *string
            );
            _int64 _wtoi64(
               
            const wchar_t *string
            );
            long atol(
               
            const char *string
            )
            long _wtol(
               
            const wchar_t *string
            )

            說明:上述函數參數為要轉換的字符串,函數的返回結構式轉換后的數據。
            如果對這個函數原型不懂得話,可看下帖,因為我剛開始看也糊涂,就csdn提問了。
            http://topic.csdn.net/u/20100126/14/9dff0450-0dd3-498a-a7ef-b3a66e512bb4.html

            1.2    代碼參考
                     因為是初學者,敲書上的代碼,開始無法實現。問別人,發現時自己文件建立方式錯誤。下面是我建立工程的步驟,以及學到的東西:
                     第一步:file->new,再選擇選項卡的project,選擇Win32 Console Application



            第二步:我這個工程的代碼選擇的第四個。其他的一些代碼,選擇第三個就足夠了,以后的一些代碼一般選擇的第三個。


            第三步:雙擊圖中選中的那個,就可以寫代碼了,具體代碼以及注釋見下文。




            //下面這個頭文件是必須包括的而且是第一個
            #include "stdafx.h"
            //文件的名字是hello
            #include "Hello.h"
            //下面用的是C++標準的寫法,不用.h的
            #include <iostream>
            using namespace std;


            //_DEBUG宏,具體的作用現在還不是很清楚
            #ifdef _DEBUG
            #define new DEBUG_NEW
            #undef THIS_FILE
            static char THIS_FILE[] = __FILE__;
            #endif

            /////////////////////////////////////////////////////////////////////////////
            // The one and only application object

            CWinApp theApp;

            using namespace std;

            int _tmain(int argc, TCHAR* argv[], TCHAR* envp[])
            {
                
            int nRetCode = 0;

                
            // initialize MFC and print and error on failure, Leave the code here would be OK.
                if (!AfxWinInit(::GetModuleHandle(NULL), NULL, ::GetCommandLine(), 0))
                
            {
                    
            // TODO: change error code to suit your needs
                    cerr << _T("Fatal Error: MFC initialization failed"<< endl;
                    nRetCode 
            = 1;
                }

                
            else
                
            {
                    
            // TODO: code your application's behavior here.
                    CString strHello = "Hello kangnixi";
                    
            //strHello.LoadString(IDS_HELLO); I will press F5 to debug.? seen>?
                    cout << (LPCTSTR)strHello << endl;
                    CString ting1
            ="1234";
                    
            int i_num=atoi(ting1);
                    cout
            <<i_num<<endl;
                    
                    CString ting2
            ="1231344.45345";
                    
            double d_num=atof(ting2);
                    cout
            <<d_num<<endl;
                }

                
            return nRetCode;
            }

            上面是我的代碼,代碼運行的時候出現一些問題,關于問題解答可見下帖:
            http://topic.csdn.net/u/20100126/16/6c71f2cc-1a3b-47d1-ba20-23e378bb35b6.html

            如果還想獲得更多關于《Visual C++代碼參考與技巧大全》的內容,可點擊下面網址,

            http://m.shnenglu.com/kangnixi/archive/2010/01/13/105591.html
            posted on 2010-01-27 12:32 煙皚 閱讀(2774) 評論(0)  編輯 收藏 引用 所屬分類: 《Visual C++代碼參考與技巧大全》學習筆記
            亚洲人成网亚洲欧洲无码久久| 久久精品国产网红主播| 久久无码人妻一区二区三区| 久久久久亚洲精品日久生情| 精品多毛少妇人妻AV免费久久| 久久99精品国产麻豆宅宅| 欧美黑人激情性久久| 99久久人人爽亚洲精品美女| 欧美精品乱码99久久蜜桃| 99久久久国产精品免费无卡顿| 久久精品二区| 久久久久四虎国产精品| 久久国内免费视频| 国产99久久精品一区二区| 香蕉久久影院| 精品久久久久久国产三级| 久久99精品国产麻豆宅宅| 狠狠综合久久综合中文88| 狼狼综合久久久久综合网| 免费精品国产日韩热久久| 久久精品国产一区| 久久精品国产亚洲av水果派 | 91久久精品91久久性色| 欧美午夜A∨大片久久 | 久久国产精品99久久久久久老狼 | 少妇久久久久久被弄高潮| 久久久久国产成人精品亚洲午夜| 996久久国产精品线观看| 久久精品国产精品亚洲精品| 色婷婷久久久SWAG精品| 久久精品亚洲精品国产欧美| 草草久久久无码国产专区| 久久久国产精品网站| 国产精品久久久久jk制服| 精品久久久久久久无码| 久久99国产精品尤物| 97超级碰碰碰久久久久| 91精品国产高清久久久久久io| 国产综合久久久久久鬼色| 久久久久久综合一区中文字幕| 国内精品伊人久久久久|