标题:不懂求教
只看楼主
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



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-228399-1-1.html




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

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