• <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>
            asm, c, c++ are my all
            -- Core In Computer
            posts - 139,  comments - 123,  trackbacks - 0

            /********************************************\
            |????歡迎轉載, 但請保留作者姓名和原文鏈接, 祝您進步并共勉!???? |
            \********************************************/


            C++異常處理一例

            作者: Jerry Cat
            時間: 2006/05/30
            鏈接:?http://m.shnenglu.com/jerysun0818/archive/2006/05/30/7851.html


            #include<fstream.h>
            #include<iostream.h>
            #include<stdlib.h>

            void main()
            {
            ??? ifstream source("c:\abc.txt");? //打開文件
            ??? char line[128];

            ??? try //定義異常
            ??? {
            ??????? if (source.fail())
            ??????? throw "txt";? //拋擲異常
            ??? }
            ??? catch(char * s)?? //定義異常處理
            ??? {
            ??????? cout<<"error opening the file "<<s<<endl;
            ??????? exit(1);
            ??? }

            ??? while(!source.eof())
            ??? {
            ??????? source.getline(line, sizeof(line));
            ??????? cout<<line<<endl;}
            ??????? source.close();
            ??? }
            }

            posted on 2006-05-30 01:38 Jerry Cat 閱讀(685) 評論(1)  編輯 收藏 引用

            FeedBack:
            # re: C++異常處理一例
            2006-05-30 20:37 | TH
            #include <cstdlib>
            #include <iostream>
            #include <fstream>
            #include <string>
            using namespace std;

            int main(int argc, char *argv[])
            {

            ifstream source("c:\\abc.txt"); //´ò¿ªÎļþ
            string line;

            try //¶¨ÒåÒì³£
            {
            if (source.fail())
            throw "txt"; //Å×ÖÀÒì³£
            }
            catch(string& s) //¶¨ÒåÒì³£´¦Àí
            {
            cout << "error opening the file " << s <<endl;
            exit(1);
            }

            while(!source.eof())
            {
            getline(source, line, '\n');
            cout<< line << endl;
            }
            source.close();

            system("PAUSE");
            return EXIT_SUCCESS;
            }
              回復  更多評論
              

            <2025年5月>
            27282930123
            45678910
            11121314151617
            18192021222324
            25262728293031
            1234567

            常用鏈接

            留言簿(7)

            隨筆檔案

            最新隨筆

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜

            久久国产精品久久| 久久久这里有精品| 国产成人久久久精品二区三区| 久久国产精品-国产精品| 久久久久久久国产免费看| 手机看片久久高清国产日韩| 久久精品免费全国观看国产| 欧洲精品久久久av无码电影 | 久久九九免费高清视频| 久久久久综合中文字幕 | 国产精品伦理久久久久久| 亚洲精品97久久中文字幕无码| 亚洲αv久久久噜噜噜噜噜| 国产三级观看久久| 久久午夜无码鲁丝片| 久久中文字幕精品| 精品99久久aaa一级毛片| 91精品国产91久久综合| 一级女性全黄久久生活片免费 | 国产精品免费久久久久电影网| 天天影视色香欲综合久久| 成人妇女免费播放久久久| 久久综合一区二区无码| 久久综合九色综合97_久久久| 久久人人爽人人爽人人爽| AA级片免费看视频久久| av国内精品久久久久影院| 少妇人妻88久久中文字幕| 亚洲国产成人久久综合一区77| 99久久99久久精品国产片| aaa级精品久久久国产片| 7777精品伊人久久久大香线蕉| 久久国产视频99电影| 久久精品国产91久久综合麻豆自制| 亚洲欧美日韩中文久久| 久久免费看黄a级毛片| 久久精品一本到99热免费| 久久久久久精品久久久久| 2021最新久久久视精品爱 | 久久精品国产亚洲AV蜜臀色欲| 久久人人爽人人澡人人高潮AV |