小编mar*_*ark的帖子

抛出'std :: length_error'的实例后终止调用

这是我在此的头一篇博文.因为我是新手,问题可能是愚蠢的.我正在编写一段代码,同时显示以下错误消息,

抛出'std :: length_error'的实例后终止调用

what():basic_string :: _ S_create

/ home/gcj/finals/home/gcj/quals where Aborted

以下是有问题的代码,特别是第39行到第52行.这对我来说很合适,因为这段代码几乎与Line64到Line79相同.

int main(){ std::vector<std::string> dirs, need; std::string tmp_str; std::ifstream fp_in("small.in"); std::ofstream fp_out("output"); std::string::iterator iter_substr_begin, iter_substr_end; std::string slash("/"); int T, N, M; fp_in>>T; for (int t = 0; t < T; t++){ std::cout<<" time "<< t << std::endl; fp_in >> N >> M; for (int n =0; n<N; n++){ fp_in>>tmp_str; dirs.push_back(tmp_str); tmp_str.clear(); } for (int m=0; m<M; m++){ fp_in>>tmp_str; need.push_back(tmp_str); tmp_str.clear(); } for (std::vector<std::string>::iterator iter = dirs.begin(); iter!=dirs.end(); iter++){ …
Run Code Online (Sandbox Code Playgroud)

c++

6
推荐指数
1
解决办法
2万
查看次数

标签 统计

c++ ×1