-
A matter of opinion
I am reading from a file of unknown length, but I need to store each line of that file for later use in my program. In addition, I will also need to use parts of each line later in my program. Should I read in each line as a string or read in per character? In your opinion as an experienced programmer, how should i approach this problem.
-
It really depends on what you want to accomplish. However it seems like you need to read each line anyways so just do that. Then when you need to specific information, you can parse each line you stored character by character. Perhaps you can be more specific on what you want.
-
Specifics
I will try to explain my program a little better. I am reading a file that contains information on people ( such as name, favorite food, favorite color, famous quote, phone number, and etc) that will only be separted by '/' on a line. Please note that each person has only one line of information. I will need to store that information so that I will not have to constantly open and close that file when i need to search for something specific or add a new person. I will also need to use each part of the person's profile either to modify or view. I was thinking of reading each line of the file and storing it into a string array. But when it comes time to store the person's data, I am not sure how to read in and separate each specific ( read in per character or as a string)? I hope I cleared things up a bit, without getting too lengthy.