WebmasterForums.NET - Webmaster Forums & Directory
 

Go Back   WebmasterForums.NET - Webmaster Forums & Directory > Design and Development > Site Programming and Coding
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Site Programming and Coding Have a problem with some code on your site? Ask our other members for advice and help.

Reply
 
Thread Tools Display Modes
Old 07-25-2006, 09:04 PM   #1
Darioush
Member
 
Darioush's Avatar
 
Join Date: Jul 2006
Location: Sunny California
Posts: 53
Darioush is on a distinguished road
Default Visual C++ coding help

Hello there. I need help in coding for visual C++. I am trying to read a text file. I want to copy only those lines which have the word "Commercials". I also want to trim the line so that I can copy only relavant information. Here is the sample text file (2 lines only):

2006.06.14 00:00:42:18 New Channel Play F:\H\Channel-S_VIDEO\Commercials\Rubicon---1.avi
2006.06.14 00:01:32:15 New Channel Play F:\H\Channel-S_VIDEO\Logos\Channel S ID Com Voice-Logo.avi

At this point, I need to know how to extract lines with the word "Commercial" and write to another file.

Thank you.

Here is my coding:

#include <fstream>
#include <string>
using namespace std;

int main () {
string line;
ifstream myfile ("type2.txt");
if (myfile.is_open())
{
while (! myfile.eof() )
{
cout <<line<<endl;
getline (myfile,line);
line.erase(23,38);

cout << line << endl;

}
myfile.close();
}

else cout << "Unable to open file";

return 0;
__________________
Napa Valley wine, wineries, on-line wine sales, lodging, vacations, golf, current events http://www.napavalley.com
Darioush is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT. The time now is 07:32 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
WebmasterForums.NET - Webmaster Forums & Directory