If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register or Login
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Any help is appreciated.

Ok, so I have this programming assignment to do. I'm having a program with it. I'm not asking to do the work for me in anyway. Just hoping on a little help to tell me what I am doing wrong. Basically the program is supposed to ask the user for an input file. Then if the input file loads successfully, then ask user to input the name of the animal. (Kind of a vet program) Then it responds with telling the user how many times the animal checked in, total cost, and avg of the cost per times visited. This was the easy part. I also made a program to make the text file. Everything runs great until you ask for the animal's name to read from the file. No matter what I put in for the name, it only reads the 2nd line from the file.

so the line I get when I enter the name "Talon" for example gets me "The animal Leo was checked into the clinic 3 times and the total charges were $30.00 with the average charge being $10.00." which is great if I was trying to get Leo's info, but not if I try for anything else.

so the line I get when I enter the name "Talon" for example gets me "The animal Leo was checked into the clinic 3 times and the total charges were $30.00 with the average charge being $10.00." which is great if I was trying to get Leo's info, but not if I try for anything else.

Are you sure it reads the second line? Maybe you should look closer.

Did you write down the steps that the program should take before writing any code? If so, did you step through your program with the debugger to check that each step is performed correctly? That's the approach you need to take to write working programs. The first step is to explain the steps of your program in normal English.

Cheers, D Drmmr

Please put [code][/code] tags around your code to preserve indentation and make it more readable.

As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

Re: Any help is appreciated.

Before posting code, please format it properly with indents etc and use code tags. These are [ code] and [ /code] (without the space!). Go Advanced, select code then click '#'

If there are 100 lines in the file and the name of the animal occurs, say, on line 92, how would you keep reading lines from the file until the animal's name is found or end of file is reached? (Hint - you need a loop).

As D_Drmmr said, you first need to design the program and check the program design is correct by working through it and making changes to the design as needed. Only when you are happy with the design do you then start coding the program from the design. You then use the debugger to make sure the program works as per the design. If the design is correct and the code correctly implements the design then the program will work.

All advice is offered in good faith only. All my code is tested (unless stated explicitly otherwise) with the latest version of Microsoft Visual Studio (using the supported features of the latest standard) and is offered as examples only - not as production quality. I cannot offer advice regarding any other c/c++ compiler/IDE or incompatibilities with VS. You are ultimately responsible for the effects of your programs and the integrity of the machines they run on. Anything I post, code snippets, advice, etc is licensed as Public Domain https://creativecommons.org/publicdomain/zero/1.0/ and can be used without reference or acknowledgement. Also note that I only provide advice and guidance via the forums - and not via private messages!