![]() |
|
#1
|
||||
|
||||
filesHello,
okay here is what I am trying to do. in my program I open up a file and use the while(getline(input,word)) loop go through the text file. After I have gone through the entire file I close it. Now, I would like to go through the file again in the same function, but when I attempt to use the loop again, I am not able to. Now I am not sure why, I am guessing the reason is because I am now at the end of the file, but I am not certain. I know there is a command that says that I open a file and start at the end. Is there possible a command that makes me start at the beginning? std::ios::ate std::ios: Thanks, Ronald __________________
This message is a natural product made from recycled electrons. The slight variations in spelling and grammar enhance its individual character and beauty and in no way are to be considered flaws or defects. |
||||
|
#2
|
||||
|
||||
some codeHere is some example code.
The file contains Cat Dog that is it. Now when I execute it. It will print out: Cat Dog and that is it. It should print go: Cat Dog Cat Dog any thoughts? CPP / C++ / C Code:
Thanks for the help Sincerely, Ronald __________________
This message is a natural product made from recycled electrons. The slight variations in spelling and grammar enhance its individual character and beauty and in no way are to be considered flaws or defects. |
|
#3
|
|||
|
|||
|
Hey,
I think I effectively answered that question in a newer post, but just to be thorough... When you open a file without any arguments, the pointer will go to the start of the file by default. Using the ios::ate argument, it will go to the end of the file, or ios::app to append to the file. I can't see anything wrong with your code. I've tried it using gcc, it works grand! GF |
|
#4
|
||||
|
||||
|
I found it. You call this right after the first time you do input.close();
input1.clear(); // Call clear() to clear the fail() flag before reopening __________________
This message is a natural product made from recycled electrons. The slight variations in spelling and grammar enhance its individual character and beauty and in no way are to be considered flaws or defects. |
Recent GIDBlog
Vista ?Widgets? on Windows XP by LocalTech
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| gxx linker accepts only 7 object files | danielxs66 | C++ Forum | 1 | 12-Dec-2003 09:27 |
| How to create batch files without DOS box? | rhino1616 | Web Design Forum | 3 | 18-Aug-2003 10:00 |
| any one knows about the address of the deleted files in FAT | shaam | C++ Forum | 1 | 09-Aug-2003 16:18 |
| Dedicated to JDS who does not like flash files | jrobbio | Open Discussion Forum | 9 | 15-Feb-2003 03:24 |
| publishing Drirector/Shockwave files ...? | darrin | Web Design Forum | 1 | 04-Oct-2002 17:21 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The