![]() |
|
#1
|
|||
|
|||
How to open file in c++hi,
fisrt, I would to thank you very much for your help. But I still want to know more about this class and how can I read data form file and write to it. And with this class I want to add item, delete item search for item. Please I need your help. |
|
#2
|
||||
|
||||
helloThis might all be review for ya. If it is I appologize. Just trying to help.
Here is how you create a file. fstream output; output.open("file.txt", ios::out); the ios::out allows you to take stuff from the file output.open("C:\\storage\\file.txt", ios::out); you need to use two \ when specifying the exact path, because when in quotes " " the backslash (\) is like a key word for example cout<<"h\ti"; will put a tab between the h and the i. output.open("file.txt", ios::in); allows you to put stuff in the file output.open("file.txt", ios::out||ios::in); allows you to do both string temp; while(getline(output,temp)) cout<<temp; The getline will get a line from output and store it in temp, because it is in the while loop it will go through the entire file. ouput<<"the dog is in the house"<<endl; this will allow you to put the string into the file. output>>temp; this will allow you to take 1 word from a file. (takes till it finds a space or tab, i beleive) output.close(); this will close the file remove("file.txt",); this will delete the file from existance Any other question, I will try to help ~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
|
|||
|
|||
Re: How to open file in c++I am trying to do something similar. i need to do a find and replace in a .txt file. can anyone advise?
thanks BMc |
|
#4
|
|||
|
|||
Re: How to open file in c++once you read the file into a string, you can use the string.find(), .erase(), .insert(), and .replace functions
|
|
#5
|
||||
|
||||
Re: How to open file in c++Quote:
Please review Guidelines #1, #2, #5, #7 (emphasis on "in progress") which I assumed you already read at least once... __________________
Cow: You're a lawyer too? Mooseblood (mosquito): Ma'am, I was already a bloodsucking parasite. All I needed was a briefcase! |
Recent GIDBlog
2nd Week of IA Training by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| open files C++ | calculus87 | CPP / C++ Forum | 4 | 09-Aug-2006 11:42 |
| Limited file size.... | lament | Apache Web Server Forum | 2 | 31-May-2004 13:35 |
| How to search a huge text file for data? | JdS | MySQL / PHP Forum | 7 | 27-May-2003 09:27 |
| Sydog's DVD to Divx Conversion Guide | asanthadenz | Computer Software Forum - Windows | 1 | 14-Mar-2003 14:08 |
| How Do i get php to find out the file type of a file for me? | viperman95833 | MySQL / PHP Forum | 2 | 08-Mar-2003 09:48 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The