Hello all, I am trying to create an array of strings read in from a file; however having no idea how long the file is, means I can't declare the array with a set size, and naturally seg faults occur....
(note, the parameter of the function is passed as void * because I'm doing thread programming.)Code:void * server_func(void *t) { cout << "Server Function: "<< (int)t << endl; //read in init_buffer_pages.dat ifstream init("test_files/init_buffer_pages.dat"); string * mem_store; for(int i = 0; !init.eof(); i++) { getline(init, mem_store[i], '\n'); cout << mem_store[i] << endl; } init.close(); }
Now, I'm sure there's some dangerously simple solution, but I can't think of it, and scouring the internet hasn't helped yet, so I'm hoping someone here can smack me on the back of the head (forum post style ) and help me out. lol.
Thank you for your time all.