Note that there are some explanatory texts on larger screens.

plurals
  1. POCan this be done without reading file twice? C++
    primarykey
    data
    text
    <p>What im doing here in main.cpp is reading a text file twice: once to remove the '\' from each path name, and again to supply the original name of the file to the SetPath() in my implementation File.</p> <pre><code>// This a read file sub-routine called in the main function. // Its purpose was intentionally set out to read the file, and pass information // to functions to MyClassFile Implementational file. // global varaible to have the file spec. char MyClass::List_[ ARRY_SZ ] = {}; int main() { .. inFile.open( MyClass::List_, ios::in ); while ( inFile.peek() != '\n' ) { inFile.get( ch ); if ( ch == 92 ) count++; } inFile.clear(); inFile.close(); inFile2.open( MyClass::List_, ios::in ); while ( inFile2.peek() != EOF ) { for( unsigned short i = 0 ; i &lt; count; i++ ) { inFile2.getline( tmpArray, ENTRY_SZ, 92 ); } inFile2.getline( tmpArray, ENTRY_SZ, '\n' ); MyObject = new MyClass( tmpArray ); // Name W/O Path LinkedObject-&gt;AddLink( MyObject ); lineCount++; } while ( inFile2.peek() != EOF ) { inFile2.getline( tmpArray, ENTRY_SZ, '\n' ); MyObject-&gt;GetPath( tmpArray ); } inFile2.clear(); inFile2.close(); } </code></pre> <p>The text file is of this format:</p> <pre><code>C:/temp/fileID C:/temp/FileID2 </code></pre> <p>I need to pass just the name to a copy constructor. I need to pass the full path name which is still in the text file to a MyClass::GetPath() function in my Implementation file.</p> <p>Is there a way to do this without reading the file twice? I hope you can see what im trying to do here. i can probably just rewind to the beginning or something like that</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