• <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://www.shnenglu.com/kangnixi/archive/2010/01/13/105591.html
            posted on 2010-01-27 12:32 煙皚 閱讀(2768) 評論(0)  編輯 收藏 引用 所屬分類: 《Visual C++代碼參考與技巧大全》學習筆記
            久久精品国产亚洲AV不卡| 久久久久久A亚洲欧洲AV冫| 亚洲精品国精品久久99热一| 国内精品久久久久久久久电影网| 99久久免费国产精品热| 亚洲午夜精品久久久久久人妖| 97久久综合精品久久久综合| yellow中文字幕久久网| 蜜桃麻豆WWW久久囤产精品| 国产亚洲欧美成人久久片| 亚洲精品99久久久久中文字幕| 日产精品久久久久久久| 久久亚洲AV成人出白浆无码国产| 久久久久久狠狠丁香| 精品久久久久久久久免费影院| 久久99国产精品久久99果冻传媒| 婷婷久久综合| 国产精品久久久久影视不卡| 亚洲人成无码网站久久99热国产| 久久精品国产福利国产秒| 久久亚洲熟女cc98cm| 久久久久综合国产欧美一区二区| 久久99亚洲网美利坚合众国| 亚洲人成无码网站久久99热国产 | 久久久SS麻豆欧美国产日韩| 久久精品国产亚洲AV高清热| 狠狠色丁香婷婷久久综合| 少妇被又大又粗又爽毛片久久黑人| 国产情侣久久久久aⅴ免费| 久久婷婷五月综合国产尤物app | 久久久精品2019免费观看| 久久免费观看视频| 伊人色综合久久天天| 无码人妻少妇久久中文字幕蜜桃| 亚洲v国产v天堂a无码久久| 久久91精品国产91久久户| 国产精品福利一区二区久久| 久久A级毛片免费观看| 久久99精品国产麻豆| 久久国产精品久久久| 久久久精品一区二区三区|