|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prob (6) | |||
In this program I am suspose to be able to edit my grades.txt file. But I'm stuck and don't know how to display my file. Any help would be nice.
Ok I added what I had on to I just forgot to include it, my main problem is that I don't know what to put in the display function in order for it to display my file. | |||
|
Last edited on
|
|||
| chrisname (4922) | |
|
Here's some advice: try asking a question. All I see up there is declarative statements. Anyway I tried compiling your code and got several syntax errors: the problem you're having is that you haven't #included anything (you need fstream, iostream and iomanip I think) and you will also get syntax errors after that: you haven't told the compiler where to find things. In C++ in the STL (standard template library) there are namespaces. One such namespace, which pretty much covers everything, is called std (standard I think). "In" that namespace is definitions for alot of what you're using. You can either type "using namespace std;" at the top (which I don't recommend) or put std:: in front of everything you used that's from the std namespace (which I do recommend) or you can put using std::<function> at the top of the file. I could go into more depth but it would take too long. If you have any specific questions ask them, I'll answer them. | |
|
|
|
| prob (6) | |
| Ok I added what I had on to I just forgot to include it, my main problem is that I don't know what to put in the display function in order for it to display my file. | |
|
|
|
| Zhuge (2205) | |
| You can use a file stream to get the data from the file then cout it. | |
|
|
|
| prob (6) | |
| Whats a file stream? | |
|
|
|
| chrisname (4922) | |
|
A data stream is a continuous flow of data. If you stream a video, for example, one computer sends a continuous flow of data to yours (usually via the internet) and your computer reads and processes it in order. Otherwise videos wouldn't work -- you'd get the data in chunks and it would be unsuitable. A file stream is where you open a file, and read the data (or stream the data) in order. That way you get the data in a continuous flow and don't have to check that it's correct, because the data is already in order. | |
|
|
|
| prob (6) | |
| Can I use this if throughout my program I am going to be editing my file? If so what do i have to change for it to work. | |
|
|
|
| chrisname (4922) | |
|
Errr... you're using ifstream right? fstream = file stream. You're using filestreams already. He just means just fstream to get the data; then print it with cout. | |
|
|
|
| prob (6) | |
| haha sorry I'm so confusing but I just really just don't know what I'm doing. I am using ifstream, how do I use ifstream to get the data and print it. | |
|
|
|
| gcampton (859) | |
|
http://cplusplus.com/doc/tutorial/files/ Try to read/learn then ask a question about what you don't understand. | |
|
Last edited on
|
|
| Zhuge (2205) | |
|
This should help: http://www.cplusplus.com/doc/tutorial/files/ Edit: Hrm, beaten. | |
|
Last edited on
|
|