高亮部分怎么了?
#include <string>
#include <fstream>
#include <iostream>
using namespace std;
void main(void){
string line,sentence, sentence_append;
ifstream infilestream("data.txt"); //File object.
char end_of_sentence[3]={'.','?','!'}; //End Mark.
int position_end=0, position_start=0; // The position which could copy to the sentence.
int sentence_size=0, append_mark; //If it needs append, append=1;
bool appendmark=0;
//cout<<"Please input a file name"<<endl;
//cin>>filename;
while (!infilestream.eof()){
getline(infilestream,line);
position_end=0;
position_start=0;
string sentence_append;
do{
position_end=line.find_first_of(end_of_sentence, position_start);
//Count the size of sentence
if(position_start==0 && position_end!=string::npos)
sentence_size=position_end;
else if (position_start!=0 && position_end!=string::npos)
sentence_size=position_end-position_start;
else if(position_start!=0 && position_end==string::npos)
sentence_size=line.length()-position_start;
else
sentence_size=line.length();
//Create the sentence
if(position_end!=string::npos && appendmark==false){
line.copy(sentence,sentence_size, position_start);
}
else if(position_end==string::npos && appendmark==false){
line.copy(sentence,sentence_size, position_start);
appendmark=true;
}
else if(position_end!=string::npos && appendmark==true){
line.copy(sentence_append, sentence_size,position_start);
sentence.append(sentence_append);
appendmark=false;
}
else if(position_end==string::npos && appendmark==true){
line.copy(sentence_append, sentence_size,position_start);
sentence.append(sentence_append);
}
position_start=position_end;
}while(position_end!=string::npos);
cout<<sentence<<endl;
}
infilestream.close();
}