Need C++ Program to Read from Text File
The basic idea is that I have a text file with lines of data.
The text file will read lines like: fNameone ele ele ele lee lee lee lee eel fNametwo ele ele ele lee lee lee lee eel eel eel eel eel eel it will continue on many different names, it will know when a new name is reached by the first character being f. each time an f line is hit, then a counter variable c needs to increase by 1 to keep track of how many names and assign the name, excluding the f to name(c) until the next f line is hit, then it will count the number of items (ele's, lee's, eel's) contained by each name and assign them to a variable (ele(c), lee(c), eel(c) respectively.) not sure this will make sense, and if it doesn't please let me know and i will try to explain it in a different way. |
I will do your homework if you buy me one years worth of beer. You deliver first.
P.S. That is quite a lot of beer, and I have expensive tastes. |
Seriously, what do you think this is here? Read the forum rules. We are not going to do youor homework for you. It won't help you either - you will not understand it if you cannot do it yourself.
We will help point you in the right direction, but you have to have a go first and ask specific questions. If you have no clue how to write a program in C++ - no idea even where to start, then you need to talk to your course tutor because you have not learned anything. |
Quote:
|
Quote:
text file contains: fSectionone ele lee eel fSectiontwo ele lee eel i need to know how to pull each line from the text file, and what function finds the first character of the string to determine if it is an f line. |
This sort of task is really much easier in awk or Perl.
For example, if I understand your description properly, this Perl program will do what you want: Code:
#!/usr/bin/perl Code:
chmod 755 myprogram Code:
./myprogram input_file Code:
Nametwo 13 |
All times are GMT -5. The time now is 08:37 AM. |