用cfree能编译的代码,在vs2010中怎么不能编译?要做些什么才能编译?
程序代码:
#include <vector> #include <deque> #include <map> #include <set> #include <list> #include <iostream> #include <fstream> using namespace std; vector<string> * retrieve_text(); vector <string> *retrieve_text() { string file_name ,retrieve_text_line ; vector<string>* retrieve_text_lines; cout << "input file name, please!\n"; cin >> file_name; ifstream in_file(file_name.c_str(),ios::in); if ( !in_file ) {cout << "file name error! unable open the file \""<< file_name << "\"\n\n"; exit(-1);} else cout << "opened the file \""<< file_name << "\"successful\n\n"; retrieve_text_lines = new vector <string>; pair<string::size_type,string::size_type> longest_line; string::size_type line_num = 0 ; while (getline(in_file,retrieve_text_line,'\n')) { cout << "read word: " << retrieve_text_line <<"\n"; if ( longest_line.second < retrieve_text_line.size() ) { longest_line.second = retrieve_text_line.size(); longest_line.first = line_num; } retrieve_text_lines->push_back(retrieve_text_line); line_num ++; } } int main() { retrieve_text(); return 0; }