Note that there are some explanatory texts on larger screens.

plurals
  1. POterminate called after throwing an instance of 'std::length_error'
    primarykey
    data
    text
    <p>this is my first post here. As i am newbie, the problem might be stupid. I was writing a piece of code while the following error message shown,</p> <p>terminate called after throwing an instance of 'std::length_error'</p> <p>what(): basic_string::_S_create</p> <p>/home/gcj/finals /home/gcj/quals where Aborted</p> <p>the following is the offending code especially Line 39 to Line 52. It is weired for me as this block of code is almost same as the Line64 to Line79.</p> <p><pre> <code></p> int main(){ std::vector&lt;std::string&gt; 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&gt;&gt;T; for (int t = 0; t &lt; T; t++){ std::cout&lt;&lt;" time "&lt;&lt; t &lt;&lt; std::endl; fp_in &gt;&gt; N &gt;&gt; M; for (int n =0; n&lt;N; n++){ fp_in&gt;&gt;tmp_str; dirs.push_back(tmp_str); tmp_str.clear(); } for (int m=0; m&lt;M; m++){ fp_in&gt;&gt;tmp_str; need.push_back(tmp_str); tmp_str.clear(); } for (std::vector&lt;std::string&gt;::iterator iter = dirs.begin(); iter!=dirs.end(); iter++){ for (std::string::iterator iter_str = (*iter).begin()+1; iter_str&lt;(*iter).end(); ++iter_str){ if ((*iter_str)=='/') { std::string tmp_str2((*iter).begin(), iter_str); if (find(dirs.begin(), dirs.end(), tmp_str2)==dirs.end()) { dirs.push_back(tmp_str2); } } } } for (std::vector&lt;std::string&gt;::iterator iter_tmp = dirs.begin(); iter_tmp!= dirs.end(); ++iter_tmp) std::cout&lt;&lt;*iter_tmp&lt;&lt;" "; dirs.clear(); std::cout&lt;&lt;std::endl; std::cout&lt;&lt;" need "&lt;&lt;std::endl; //processing the next for (std::vector&lt;std::string&gt;::iterator iter_tmp = need.begin(); iter_tmp!=need.end(); ++iter_tmp) std::cout&lt;&lt;*iter_tmp&lt;&lt;" "; std::cout&lt;&lt;" where "; for (std::vector&lt;std::string&gt;::iterator iter = need.begin(); iter!=need.end(); iter++){ for (std::string::iterator iter_str = (*iter).begin()+1; iter_str&lt;(*iter).end(); ++iter_str){ if ((*iter_str)=='/') { std::string tmp_str2((*iter).begin(), iter_str); if (find(need.begin(), need.end(), tmp_str2)==need.end()) { need.push_back(tmp_str2); } } } } for (std::vector&lt;std::string&gt;::iterator iter_tmp = need.begin(); iter_tmp!= need.end(); ++iter_tmp) std::cout&lt;&lt;*iter_tmp&lt;&lt;" "; need.clear(); std::cout&lt;&lt;std::endl; //finish processing the next } for (std::vector&lt;std::string&gt;::iterator iter= dirs.begin(); iter!=dirs.end(); iter++) std::cout&lt;&lt;*iter&lt;&lt;" "; std::cout&lt;&lt;std::endl; for (std::vector&lt;std::string&gt;::iterator iter= need.begin(); iter!=need.end(); iter++) std::cout&lt;&lt;*iter&lt;&lt;" "; std::cout&lt;&lt;std::endl; fp_out.close(); } </code></pre> <p></p> <p>best regards, Mark</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload