Quote:
Originally posted by jello
I'm working on a program in which I need to read into a list, from text file: a task name, it's due time, the hours needed to complete the task, and the number of points the task is worth.
I'm using a simple structure:
Code:
struct Task
{
string name;
int dueTime;
int hoursNeededToComplete;
int nmbrPoints;
};
|
Since you're using
string you could be coding in C++, here I would just overload the
>> operator, to put everything into your struct, but to make that work you would have to rename your struct to class.
however
Since it is a struct you're defining here, then it indicates you're using strict ansi C, then I would sugest you to look at fopen(), fscanf() and fclose()
Quote:
The format of the text file is as follows:
name dueTime hoursNeededToComplete nmbrPoints
name dueTime hoursNeededToComplete nmbrPoints
name dueTime hoursNeededToComplete nmbrPoints
etc.
|
Good format, are those tabs between the columns ? If so, fscanf() might be what you are looking for...
Altho a wee bit of code to give anyone an idear where your thoughts are would help some more.