| | |
Saving Entered Data
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: May 2006
Posts: 1
Reputation:
Solved Threads: 0
<<split from: http://www.daniweb.com/forums/thread42172.html>>
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
•
•
•
•
Originally Posted by weehoong
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.:cheesy:
anyway, ive got this assignent to finish off and are having problems with a small block of codes here.
C++ Syntax (Toggle Plain Text)
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!
can anyone help me
Last edited by Dave Sinkula; May 20th, 2006 at 9:06 pm.
![]() |
Similar Threads
- Saving Game Data - Plaintext vs. XML (Game Development)
- Validating data in a field to a existing data stored in the database (PHP)
- Hey check out my prog. It has an error can u find it? (Java)
- need halp passing array data (C#)
- saving xml file from servlet request instance (Java)
- vb and excel password and username (Visual Basic 4 / 5 / 6)
- Upgrading to Win2000 from Win98 advice wanted! (Windows NT / 2000 / XP)
- How do I disable this IE form feature? (Web Browsers)
Other Threads in the C++ Forum
- Previous Thread: Memory game with c++ console applicaton
- Next Thread: Problem with user input
| Thread Tools | Search this Thread |
api array based beginner binary bitmap c++ c/c++ calculator char char* class code coding compile compiler console conversion count database delete deploy developer directshow dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int java lib linkedlist linker list loop looping loops map math matrix memory multiple news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings temperature template test text text-file tree unix url variable vector video visualstudio win32 windows winsock word wordfrequency wxwidgets




:cheesy: 


