有关 c++ 的问题
#include <iostream>
#include <fstream>
#include <sstream>
#include <vector>
#include <iterator>
#include <algorithm>
using namespace std;
string read_file_into_string()
{
ifstream ifile( "test1.txt" );
if( !ifile )
cout << "error\n";
ostringstream buf;
char ch;
while ( buf && ifile.get( ch ) )
buf.put( ch );
return buf.str();
}
int main()
{
string text = read_file_into_string();
cout << text;
vector<string::size_type> lines_of_text;
string::size_type pos = 0;
while( pos != string::npos )
{
pos = text.find( '\n', pos );
lines_of_text.push_back( pos );
} //调试时这里变成了死循环,跳不出来;高手指点
ostream_iterator<string::size_type> out( cout , " " );
copy( lines_of_text.begin(), lines_of_text.end(), out );
cin.get();
}
#include <fstream>
#include <sstream>
#include <vector>
#include <iterator>
#include <algorithm>
using namespace std;
string read_file_into_string()
{
ifstream ifile( "test1.txt" );
if( !ifile )
cout << "error\n";
ostringstream buf;
char ch;
while ( buf && ifile.get( ch ) )
buf.put( ch );
return buf.str();
}
int main()
{
string text = read_file_into_string();
cout << text;
vector<string::size_type> lines_of_text;
string::size_type pos = 0;
while( pos != string::npos )
{
pos = text.find( '\n', pos );
lines_of_text.push_back( pos );
} //调试时这里变成了死循环,跳不出来;高手指点
ostream_iterator<string::size_type> out( cout , " " );
copy( lines_of_text.begin(), lines_of_text.end(), out );
cin.get();
}
...全文
相关推荐
C++洛谷 1049 装箱问题.cpp
【C++】洛谷 1049 装箱问题.cpp【C++】洛谷 1049 装箱问题.cpp【C++】洛谷 1049 装箱问题.cpp【C++】洛谷 1049 装箱问题.cpp【C++】洛谷 1049 装箱问
leetcode答案-cpp-leetcode:C++中流行的leetcode问题的答案
这个压缩包文件“cpp-leetcode-master”显然包含了C++语言解答LeetCode上流行问题的源代码。以下是关于这个主题的一些详细知识点:1.
基于C++的完全背包问题(.cpp)
基于C++的完全背包问题(.cpp)
cpp_laboratory:实验室测试我的CPP问题
在“cpp_laboratory”这个项目中,我们可以看到一个针对C++编程语言的实验室测试集,主要用于解决和探讨与C++相关的各种问题。
cpp代码-背包问题2
在这个场景中,“cpp代码-背包问题2”可能指的是用C++编程语言实现的一个特定的背包问题算法。


