• <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://www.shnenglu.com/kangnixi/archive/2010/01/13/105591.html
            99久久人妻无码精品系列蜜桃| 久久婷婷五月综合成人D啪| 日本精品久久久久久久久免费| 久久九九免费高清视频| 一级A毛片免费观看久久精品| 国产精品久久久久久久| 久久久久99精品成人片三人毛片 | 久久精品国产亚洲av水果派| 久久亚洲国产成人精品性色| 国产高清美女一级a毛片久久w| 狠狠色综合久久久久尤物| 亚洲一级Av无码毛片久久精品| 精品国产乱码久久久久软件| 国产三级久久久精品麻豆三级 | 亚洲午夜久久久影院伊人| 久久96国产精品久久久| 婷婷久久精品国产| 东京热TOKYO综合久久精品| 久久人人爽人人澡人人高潮AV| 蜜桃麻豆www久久| 7777精品久久久大香线蕉| 久久香蕉一级毛片| 久久精品国产99国产精品亚洲| 青青草国产精品久久| 亚洲∧v久久久无码精品| 大香伊人久久精品一区二区| 久久久久97国产精华液好用吗| 无码精品久久久久久人妻中字| 亚洲国产精品无码久久久久久曰| 久久久久久久综合日本亚洲| 波多野结衣AV无码久久一区| 亚洲国产精品成人久久蜜臀| 久久久久久无码国产精品中文字幕| 久久精品无码午夜福利理论片| 久久精品中文字幕一区| 久久久亚洲精品蜜桃臀| 国产亚洲精久久久久久无码AV| 日韩欧美亚洲综合久久影院d3| 久久久久久毛片免费播放| 99精品国产在热久久无毒不卡 | 人人狠狠综合88综合久久|