Need help Text File in C++

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2008
Posts: 10
Reputation: mugun has a little shameless behaviour in the past 
Solved Threads: 0
mugun mugun is offline Offline
Newbie Poster

Need help Text File in C++

 
0
  #1
Sep 19th, 2008
Hello everyone...i need help with text file in c++,i know that we can append like ios::app and into a text file.....i need help in inserting a particular string to a particular line in a text file.....is that possible....So far i only knw tht it will append at the bottom of the text file

this is the code i did for the appending part......
ofstream enter_names("names.txt", ios::app);
ofstream enter_id("id.txt", ios::app);
cout<<"Enter Name:";
getline(cin,member_name);
cout<<"Enter Id:";
getline(cin,card_id);
enter_names<<member_name<<endl;
enter_id<<card_id<<endl;//lets say i want to store card id in line 5 of the text file.
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,660
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 723
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Need help Text File in C++

 
1
  #2
Sep 19th, 2008
>i need help in inserting a particular string to a particular line in a text file.....is that possible
It's possible, but not directly. You need to rewrite the file from beginning to end and insert your modified parts at the appropriate place.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 10
Reputation: mugun has a little shameless behaviour in the past 
Solved Threads: 0
mugun mugun is offline Offline
Newbie Poster

Re: Need help Text File in C++

 
0
  #3
Sep 24th, 2008
yea....i did sumthin like,i stored em all in a vector,thn i remove wat i the user chooses,and thn delete wat the user chooses...i works....this is a library system....so i need to add the date...any std library in c++ can handle the date?....so i can plus 29/9/2008 + 5 Days will be 3/10/2008
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,660
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 723
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: Need help Text File in C++

 
1
  #4
Sep 24th, 2008
>any std library in c++ can handle the date?
Yes, and you would have figured that out by looking in a C++ reference. There's a header called <ctime>, and it contains the functions and types you need. Specifically, struct tm, mktime, and localtime.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Join Date: Sep 2008
Posts: 10
Reputation: mugun has a little shameless behaviour in the past 
Solved Threads: 0
mugun mugun is offline Offline
Newbie Poster

Re: Need help Text File in C++

 
0
  #5
Sep 24th, 2008
Thx Narue...i will try the ctime function...
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC