Note that there are some explanatory texts on larger screens.

plurals
  1. POIfstream getting information from a textfile
    primarykey
    data
    text
    <p>At the moment I'm trying to get to create a race track that has all of the textures on the ground loaded via a textfile. An example is this:</p> <p><code>0, 0, 1, 1, 1, 1, 0, 0</code></p> <p><code>0, 1, 0, 0, 0, 0, 1, 0</code> </p> <p><code>0, 0, 1, 1, 1, 1, 0, 0</code></p> <p>The ground itself is simply a grid.</p> <p>At the moment the code I have to get information from text file is as follows:</p> <pre><code> string line; ifstream myfile ("track1.txt"); if (myfile.is_open()) { while ( !myfile.eof() ) { getline( myfile, line, ','); if (line == '0') { const wstring textureFileName=TEXT("crate.jpg"); } myfile&gt;&gt;line; } myfile.close(); } </code></pre> <p>When I build this code, how ever I get the following error:</p> <blockquote> <p>binary '==' : no operator found which takes a right-hand operand of type</p> </blockquote> <p>Then if I change the double equals sign to a single I get the following error:</p> <blockquote> <p>error C2451: conditional expression of type 'std::basic_string&lt;_Elem,_Traits,_Ax>'is illegal 'char' (or there is no acceptable conversion)</p> </blockquote> <p>Is there something I'm missing that is causing the error?</p> <hr> <p>Sorry for my lack of proper detail. </p> <p>Thank you chaosTechnician. Will the val work on multiple lines in the text file? Like this</p> <pre><code>0 0 1 1 1 1 0 0 0 1 0 0 0 0 1 0 1 0 0 0 0 0 0 1 0 1 0 0 0 0 1 0 0 0 1 1 1 1 0 0 </code></pre> <p>I mean, is there anything else I need to type to get the computer to realise the line has ended?</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.
    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