![]() |
| ||
| Reading/writing .txt files into an array I am writing a program and I have a .txt file that has a some information about people. I would like to write that information into an array and then display that information about the person. The problem is that I don't know how many names will be in the .txt file, or how to write that information to the file. Here is what I have so far. #include <iostream> and here is my hourlyEmployee class. #include "Employee.h" I don't really know how to put the .txt information into the array so if anyone could give me some idea's or any help at all that would be great. Thanks |
| ||
| Re: Reading/writing .txt files into an array That while statement on line 13 is incorrect because eof() doesn't work like that. Instead, code it something like this string line; |
| ||
| Re: Reading/writing .txt files into an array Quote:
|
| ||
| Re: Reading/writing .txt files into an array Also thanks for changing the code |
| ||
| Re: Reading/writing .txt files into an array Quote:
|
| ||
| Re: Reading/writing .txt files into an array Quote:
the .txt file is... Joe Cruise E1111 Bill Bones E2222 Sue Smith E3333 Tom Turpin E4444 Ron Stewart E5555 Mindy Sweet E7777 and the class file employee has string firstName, string lastName, string employeeID. i want to use an array in my int main to write those names and ID's to the class.... is that possible and if so how would I even start to do it? |
| ||
| Re: Reading/writing .txt files into an array The input line can be split using stringstream class #include <sstream> |
| ||
| Re: Reading/writing .txt files into an array Yes, it's possible. Make an array of the class employee. As you read the file, load the class. You can then access employee[x].FirstName, etc. |
| All times are GMT -4. The time now is 2:18 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC