Note that there are some explanatory texts on larger screens.

plurals
  1. POTrying to read text file C++
    primarykey
    data
    text
    <p>Using Dev C++, we are trying to get the code to read it one line at a time and store it in an array. We don't seem to get any official errors, but a windows box pops onto the screen to find a solution for the errors? </p> <pre><code>#include &lt;iostream&gt; #include &lt;fstream&gt; #include "AddressBook.h" const int ADDR_BOOK_SZ = 1000; void AddNewAddressBook(AddressBook* current); void PrintAddresses(AddressBook* addrBook); using namespace std; int main(int argc, char** argv) { AddressBook addrBook[ADDR_BOOK_SZ]; AddressBook* current; char* path; ifstream file; char* placeholder; bool running = true; char entered; while(running) { //print directions cout &lt;&lt; "a) Open an address book file\n" &lt;&lt; "b) Add a new address book entry\n" &lt;&lt; "c) Print the contents of current address book\n" &lt;&lt; "d) Quit" &lt;&lt; endl; //get the user's command cin &gt;&gt; entered; //set pointer to the current addressbook current = addrBook + AddressBook::entryCnt_; if(entered == 'a') { cout &lt;&lt; "Please enter the file path for the address book file: " &lt;&lt; '\n'; cin &gt;&gt; path; file.open(path); int i = 0; while(!file.eof()){ //getline(placeholder, 100); file &gt;&gt; placeholder; addrBook[i].SetFirstName(placeholder); file &gt;&gt; placeholder; addrBook[i].SetFirstName(placeholder); file &gt;&gt; placeholder; addrBook[i].SetStreetNum((int)placeholder); file &gt;&gt; placeholder; addrBook[i].SetStreetName(placeholder); file &gt;&gt; placeholder; addrBook[i].SetCity(placeholder); file &gt;&gt; placeholder; addrBook[i].SetState(placeholder); file &gt;&gt; placeholder; addrBook[i].SetZipCode((int)placeholder); i++; } } else if(entered == 'b') { current-&gt;AddEntryFromConsole(); } else if(entered == 'c') { for(int i = 0; i &lt; AddressBook::entryCnt_; i++) { addrBook[i].PrintToConsole(); } } else if(entered == 'd') { return 0; } else { cout &lt;&lt; "Wrong input entered. Try again." &lt;&lt; endl; } } file.close(); </code></pre> <p>}</p> <p>Thank you for any and all help!</p>
    singulars
    1. This table or related slice is empty.
    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