Note that there are some explanatory texts on larger screens.

plurals
  1. POSet illegal indirection error?
    text
    copied!<p>I'm getting a "set illegal indirection error" but I can't figure out what I am doing wrong. What I am trying to do is take input from input.txt file that has a form</p> <pre><code>string1 string2 string3 string4 etc. </code></pre> <p>And number the strings in ascending order without duplicates, then use them in some functions and store the values in struct StringInt. But I am getting this weird error and I don't know where to start fixing it.</p> <pre><code>struct StringInt { std::string name; // associate name and number for each input string int number; }; int main(int argc, char* argv[]) { tot_strings = 100; std::string vert1, vert2; std::set&lt;std::string&gt; inGraph(0, tot_strings); // this is the set in question std::set&lt;std::string&gt;::iterator sit; std::vector&lt;StringInt&gt; stringInts(tot_strings); // Edit: forgot to mention this initially StringInt* si; int icv1, icv2; std::ifstream myfile2 ("input.txt"); if (myfile2.is_open()) { while(myfile2 &gt;&gt; vert1 &gt;&gt; vert2) { myfile2 &gt;&gt; vert1 &gt;&gt; vert2; if (inGraph.find(vert1) != inGraph.end()) { // not sure if I do this correctly icv1 = i++; si-&gt;name = vert1; si-&gt;number = icv1; inGraph.insert(vert1); // here's the insert that might be stringInts.push_back(*si); // causing of the error } else { icv1 = si-&gt;number; } if (inGraph.find(vert2) != inGraph.end()) { icv2 = i++; si-&gt;name = vert1; si-&gt;number = icv2; inGraph.insert(vert2); stringInts.push_back(*si); } else { icv1 = si-&gt;number; } // use icv1 and icv2 as int inputs in functions below } </code></pre> <p>Does what I have make sense and how can I go about fixing the "set illegal indirection error"? Edited: included std::vector stringInts(tot_strings) that I had in my code but forgot to include in the example.</p>
 

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