Note that there are some explanatory texts on larger screens.

plurals
  1. POFstream gives error when reused on a file
    primarykey
    data
    text
    <p>I have two text files. Original Output:</p> <pre><code>Log.txt Joe hello Joe gargabash Joe random unnecessary text Hello How are you? </code></pre> <p>Log2.txt is another text file that is initially blank.</p> <p>When I run this code, it succesfully copies all of the lines that don't start with Joe. However, I want to copy the text back to the original .txt. When I uncomment out the selection I commented to try to do that, I get errors. Anyone know what i'm doing wrong? Thanks so much for reading all of this mess. For clarification, the bool STRINGCONTAINS(int, char, char, int) checks if a char array matches with another char array.</p> <pre><code>#include &lt;WinSock2.h&gt; #include &lt;Windows.h&gt; #include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;stdlib.h&gt; #include &lt;string&gt; using namespace std; bool STRINGCONTAINS(bool CaseSensitive, //If this is true, we are checking a case sensitive string, if it's false, we're not. char * input1, // First string [Type: Char Array] char * input2, //Second String [Type: Char Array] int MAXSTRINGLENGTH) // Integer representing max possible length of string. { if (CaseSensitive) { for(int i=0;i&lt;MAXSTRINGLENGTH;i++) { if (*input1 == *input2) { input1++; input2++; } else { return 0; } } } else { int char1, char2; for(int i=0;i&lt;MAXSTRINGLENGTH;i++) { char1 = *input1; char2 = *input2; if (char1 == char2 || char1 == (char2+32) || char2 == (char1+32)) { input1++; input2++; } else { return 0; } } } return 1; } int main() { int input; char * loadedline = new char[192]; ifstream log; ofstream templog; log.open("log.txt"); templog.open("log2.txt"); while(log.getline(loadedline,sizeof(log))) { if (!STRINGCONTAINS(0,loadedline,"joe",3)) { cout &lt;&lt; loadedline &lt;&lt; endl; templog &lt;&lt; loadedline &lt;&lt; endl; } } log.close(); templog.close(); /*ifstream templog2; ofstream log2; templog2.open("log2.txt"); log2.open("log.txt"); while(templog2.getline(loadedline,sizeof(templog2))) { log2 &lt;&lt; loadedline &lt;&lt; endl; } templog2.close(); log2.close;*/ delete[] loadedline; cin &gt;&gt; input; return 0; } </code></pre>
    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