View Single Post
Old May 30th, 2006, 4:36 AM   #1
myName
Programmer
 
Join Date: Oct 2005
Posts: 48
Rep Power: 0 myName is on a distinguished road
Is there a way to delete a line from a file?

Is there a way to delete a line from a text file?

int	posEndIdx;
	int	ipos=0;
	string sLine;
	string sKeyWord;
	const string sDelim ( "]" );

	try
	{
		fstream myInputFile("D:\\Logs\\CMS\\UnSended\\upload.text");
			
		if( myInputFile.is_open() )
		{
			while( !myInputFile.eof() )
			{
				getline(myInputFile, sLine);
				
				if(sLine.empty())
					continue;

				posEndIdx = sLine.find_first_of(sDelim);
				sKeyWord = sLine.substr( posEndIdx+1, (sLine.length() - (posEndIdx+1)) );
				cout<<sKeyWord<<endl;

				//*******delete the line*******
			}

			myInputFile.close();
		}
	}
	catch(...)
	{
		cout<<"Exception"<<endl;
	}
myName is offline   Reply With Quote