| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 721 人关注过本帖
标题:不懂求教
只看楼主 加入收藏
hhitjsj021
Rank: 1
等 级:新手上路
帖 子:13
专家分:0
注 册:2005-9-17
收藏
 问题点数:0 回复次数:0 
不懂求教
程序代码:
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<algorithm>
#include<stdlib.h>
using namespace std;

vector<string> *tvec()
{
    string filename;
    cout<<"please enter filename:"<<endl;
    cin>>filename;

    //open file
    ifstream infile(filename.c_str(),ios::in);

    //if(!filename)
    if(!infile.is_open())
    {
        cout<<"unable to open the file "<<filename;
        exit(-1);
    }    
    else
        cout<<"\n";

    vector<string> *lines_of_text=  new vector<string>;
    string textline;
    typedef pair<string::size_type,int> stats;
    stats maxline;
    int numline=0;

    while (getline(infile,textline,'\n'))
    {
        cout<<"lineread:"<<textline<<'\n';
        if(maxline.first<textline.size())   //这里的maxline.first是什么意思啊?不明白 
        {
            maxline.first=textline.size();
            maxline.second=numline;
        }
        lines_of_text->push_back(textline);
        ++numline;
    }
    return lines_of_text;
}

int main()
{
    vector<string>* evec;
    evec=tvec();
    return 0;
    
} 
搜索更多相关主题的帖子: vector std string cout 
2008-08-15 10:05
快速回复:不懂求教
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.018216 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved