>Open the file, you want to write to.
Aren't you forgetting to prompt the user for the filename to write to?
>If file did not open try again.
That's not necessarily the best method, because most likely if it fails the file is being used by another program, so if the file cannot be opened, usually you prompt the user for another filename (in the case of reading a file), or you just terminate the program. There's no use for wasting CPU cycles on a file that refuses to open.
>Write data to the file.
What data? When did the user enter any data?
>If not keep writing.
Keep writing? How? You've forgotten to declare a loop, which is important...
John A
Vampirical Lurker
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
>Well thats what I men by that.
Since when did "men" come into this discussion?
>What do you mean by: Prompt the user for the filename to write to?
I mean that your program has to first ask the user for the filename, store it in a variable, and then use this variable to open the file.
>I had no idea there were 2 steps, in my mind you will only need one.
It all depends how generalistic you want to be. What I'm saying is the basic steps it would take you to write it in a language such as C/C++, however you could break it down even further into Assembly if you wanted.
>I was thinking of: File open good, if not try a different file.
Hm, and what happens if that file doesn't work? You have to cover all (or as many as are reasonable) possiblities. If the hard drive's permissions are read-only, your program would just stall or something.
>I was going to declare the data and enter it here.
Then say so. We, and your instructor can't read what you are thinking, so write it down.
>I ment to say are you done? If not keep going.
Ah, but how is the program supposed to know WHERE to keep going? Which of your previous statements is it supposed to jump to? You must explicity show that there's a loop, and that you're not just going to use a stupid GOTO to create it.
John A
Vampirical Lurker
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
The only things I would do different is that I'd explicity state that when the user enters data, it's stored in some variables. And I'd also say something like "Loop until user decides to quit" and another statement saying "End of loop".
But other than those few minor points, it's pretty much good-to-go.
John A
Vampirical Lurker
7,630 posts since Apr 2006
Reputation Points: 2,240
Solved Threads: 339
I would do it like this:
1. Ask the user for file name of file they wish to write data to.
2. Store file name in to a variable.
3. Open file.
4. If file not open
issue an error message
else
Start a loop:
A. Enter user data. (implies ask/accept)
B. If finished, exit loop (5)
C. Write data to file
D. Continue loop
5. Close file
WaltP
Posting Sage w/ dash of thyme
10,506 posts since May 2006
Reputation Points: 3,348
Solved Threads: 944