• <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 煙皚 閱讀(2768) 評論(0)  編輯 收藏 引用 所屬分類: 《Visual C++代碼參考與技巧大全》學習筆記
            久久91亚洲人成电影网站| 久久久噜噜噜久久中文字幕色伊伊| 久久久久久久综合日本| 亚洲国产高清精品线久久 | 久久久久亚洲AV无码专区桃色| 亚洲v国产v天堂a无码久久| 无码人妻久久一区二区三区免费| 国产精品久久久久…| 亚洲Av无码国产情品久久| 99re久久精品国产首页2020| 久久婷婷五月综合色99啪ak| 久久久久久毛片免费播放| 伊人情人综合成人久久网小说| 国产一级做a爰片久久毛片| 中文字幕无码久久精品青草 | 91精品国产综合久久久久久| 九九热久久免费视频| 久久夜色精品国产欧美乱| 久久久久国产一区二区| 久久天堂电影网| 日韩久久久久久中文人妻| 亚洲精品NV久久久久久久久久| 老司机国内精品久久久久| 久久久久亚洲av无码专区喷水 | 久久香蕉综合色一综合色88| 7777久久久国产精品消防器材| 久久久久九国产精品| 香蕉久久一区二区不卡无毒影院 | 88久久精品无码一区二区毛片| 久久亚洲AV永久无码精品| 久久精品国产99国产电影网| 97精品依人久久久大香线蕉97 | 久久久久亚洲AV成人网| 国产精品久久久久jk制服| 精品久久久一二三区| 久久综合视频网站| 亚洲欧美成人久久综合中文网| 久久久WWW成人免费毛片| 青青热久久国产久精品 | 久久亚洲sm情趣捆绑调教| 久久99热这里只有精品66|