<<split from: [thread]42172[/thread]>>

Hi there guys!

Just want to say these communities are great! i've really benefited alot from the forum and its tutorials. Special thanks to FireNet and his file handling tutorials. It really helped me alot! Not forgetting, thanks alot to all of the members here too. :idea: :cheesy:

anyway, ive got this assignent to finish off and are having problems with a small block of codes here.

class video
{

protected:

	struct videoData
	{
		char title[30];
		char star1[30];
		char star2[30];
		char producer[30];
		char director[30];
		char productionCo[30];
		int copiesInStock;
		int totalCopiesInStock;
	};

public:


//////[Modify Record]/////////////////////////////////////////////////////

	void modifyVideoList()
	{

		fstream file4;
		videoData fields;
		char titleTemp [30];

		int flag=0;

		cout<<"\t\n\nEnter title of video to search: \n";
		cin.getline(titleTemp,30);

		file4.open("videolist.dat", ios::app | ios::out | ios::in | ios::binary);
		file4.seekg(0, ios::beg);
		file4.read( reinterpret_cast<char*>(&fields), sizeof(fields) );

		while ( !file4.eof())
		{

				
			if(strcmp(fields.title,titleTemp)==0)
			{
				
				//Display old record information
				cout<< "\n\t::Displaying '" << fields.title << "'  information::\n";
				cout<< "Movie Title: " << fields.title <<endl;
				cout<< "Movie Star 1: " << fields.star1 <<endl;
				cout<< "Movie Star 2: " << fields.star2 <<endl;
				cout<< "Movie Producer: " << fields.producer <<endl;
				cout<< "Movie Director: " << fields.director <<endl;
				cout<< "Production Company: " << fields.productionCo <<endl;
				cout<< "Number of Copies In Stock: " << fields.copiesInStock <<endl;
				cout<< "Total Copies in Store: " << fields.totalCopiesInStock <<endl;

				cout<< "\n\n";

				//Enter new record information
				cout<< "\n\n"<<endl;
				cout<< "\t::Enter new information::\n"<<endl;

				cout<<"Video Title: ";
				cin.getline(fields.title, 30);

				cout<<"Movie Star 1: ";
				cin.getline(fields.star1, 30);

				cout<<"Movie Star 2: ";
				cin.getline(fields.star2, 30);

				cout<<"Movie Producer: ";
				cin.getline(fields.producer, 30);

				cout<<"Movie Director: ";
				cin.getline(fields.director, 30);

				cout<<"Production Company: ";
				cin.getline(fields.productionCo, 30);

				cout<<"Number of Copies in Stock: : ";
				cin>> fields.copiesInStock;

				cout<<"Total Copies in Store: ";
				cin>> fields.totalCopiesInStock;

				file4.seekp(0, ios::beg);
				file4.write( reinterpret_cast<char*>(&fields), sizeof(fields) );
				
		
			}
				file4.read( reinterpret_cast<char*>(&fields), sizeof(fields) );
			
		}

		if(flag==1)
		{
			cout<<"Video title not found!"<<endl;
			fflush(stdin);
		}

		cout<< "\nRecord has been updated!\n" <<endl;
		
		file4.close();
		system("Pause");
		system("Cls");


	}

what im trying to do here is to create a file handling database with add, display records and modify records for a video rental store. the problem here is the modify record section where i cant get any datas into my file.

can anyone help me with this? this block of codes are copied from my header file so if anyone needs the whole thing please tell me so. thanks alot! ;)

hi, well i m too in creation of something similar to your code. But i need help in generating a file whatever the user does while interacting with executed code...i mean saving the output of executed code in a file....
can anyone help me

just open the file for writing, then output all user input to that file. Yes, you have to add additional code to do that. No, you can't have cout and cin do two things at the same time (write/read to/from the screen and write to a file too).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.