• <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++博客 :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
              117 Posts :: 2 Stories :: 61 Comments :: 0 Trackbacks

            常用鏈接

            留言簿(8)

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            1、 將“字符串”轉(zhuǎn)化換為“整數(shù)”

                  1.1    轉(zhuǎn)換函數(shù)

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

            函數(shù)的原型如下:

            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
            )

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

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



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


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




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


            //_DEBUG宏,具體的作用現(xiàn)在還不是很清楚
            #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;
            }

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

            如果還想獲得更多關(guān)于《Visual C++代碼參考與技巧大全》的內(nèi)容,可點擊下面網(wǎng)址,

            http://m.shnenglu.com/kangnixi/archive/2010/01/13/105591.html
            欧美日韩成人精品久久久免费看| 中文字幕无码av激情不卡久久| 99久久99这里只有免费的精品| 国产精品久久久久久福利69堂| 精品多毛少妇人妻AV免费久久| 久久亚洲AV成人无码软件| 精品久久久噜噜噜久久久| 亚洲国产小视频精品久久久三级 | 香蕉久久av一区二区三区| 色综合久久综精品| 久久亚洲日韩精品一区二区三区| 一级做a爰片久久毛片16| 久久久www免费人成精品| 久久久久亚洲av毛片大| 国产精品99久久精品| 久久亚洲AV无码精品色午夜麻豆| 久久久国产精品| 久久综合九色综合久99 | 久久精品国产99国产精品| 粉嫩小泬无遮挡久久久久久| 久久无码专区国产精品发布| 精品久久久久久国产三级| 精品久久久久久亚洲| 久久精品国产亚洲AV电影| 色综合久久久久综合体桃花网| 久久综合九色欧美综合狠狠| 国内精品久久九九国产精品| 无码人妻久久一区二区三区免费| 亚洲国产精品综合久久网络| 久久综合九色欧美综合狠狠| 久久精品国产亚洲av瑜伽| 狠狠色综合久久久久尤物| 久久久久99精品成人片三人毛片 | 日本五月天婷久久网站| 亚洲国产高清精品线久久| 伊人热热久久原色播放www| 午夜视频久久久久一区| 中文字幕无码久久久| 精品国产乱码久久久久久呢 | 亚洲精品无码久久一线| 亚洲AV无码久久精品狠狠爱浪潮 |