fynaz 0 Report post Posted September 18, 2005 what's wrong ngan coding ni ek?coding ni tk full...nk display data customer baru tk appear pon... pening arrr...pastu,camane nk add function delete record ek??anyone please help me a.s.a.p!! Please..i'm helpless........ using namespace std;static int p = 0;class a{ char movieTitle[15], cast[10], date[5], time[5], theatre[10], numOfshow[10], seat[8][4][10]; char name[20]; char ic[15]; char telno[12]; public: //set functions void addMovie(); void getcustomerdata(); void showdata(); void displaySeat(); void empty(); void display(); void movieDetails(); void position(int i); char *getdate() { return date; } char *getic() { return ic; }}movie[10];void vline(char ch){ for (int i=80;i>0;i--) cout<<ch;}void a::addMovie(){ cout<<"\t\t\t:: Add Movie ::\n"; cout<<"\t\t\t---------------\n\n"; cout<<"\t\t\tEnter movie title : "; cin>>movie[p].movieTitle; cout<<"\t\t\tEnter cast's name : "; cin>>movie[p].cast; cout<<"\t\t\tDate : "; cin>>movie[p].date; cout<<"\t\t\tTime : "; cin>>movie[p].time; cout<<"\t\t\tTheatre : "; cin>>movie[p].theatre; cout<<"\t\t\tNumber of show : "; cin>>movie[p].numOfshow; movie[p].empty(); p++;}void a :: getcustomerdata(){ cout<<"\t\t\t:: New Customer Entry ::\n"; cout<<"\t\t\t------------------------\n\n"; cout<<"\t\t\tEnter Name :"; cin>>movie[p].name; cout<<"\t\t\tEnter NRIC :"; cin>>movie[p].ic; cout<<"\t\t\tEnter TelNo :"; cin>>movie[p].telno; movie[p].empty(); p++;}void a :: showdata(){ cout<<"\t\t\t:: Customer Record ::"<<endl; cout<<"\t\t\t---------------------\n"; cout<<"\t\t\tName :"<<movie[p].name<<endl; cout<<"\t\t\tNRIC :"<<movie[p].ic<<endl; cout<<"\t\t\tTelNo :"<<movie[p].telno<<endl; movie[p].empty(); p++;} Quote Share this post Link to post Share on other sites
encik pot pet 0 Report post Posted September 18, 2005 (edited) mesti awak copy paste jer ni.. sebab aku tak nampak pulak function utk store record tu dalam file seperti .dat or anythingbtw, utk tidak menghampakan dan agar tak cluecless lagi, ni code aku buat utk project bagi subject c programming dulu2 BOOL LoadFile(HWND hwnd, LPCTSTR pszFileName) { HANDLE hFile; BOOL bSuccess; hFile = CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if(hFile != INVALID_HANDLE_VALUE) { DWORD dwFileSize; dwFileSize = GetFileSize(hFile, NULL); if(dwFileSize != 0xFFFFFFFF) { if(p_array != NULL) { DWORD dwRead; if(ReadFile(hFile, p_array, dwFileSize, &dwRead, NULL)) { total_acc = p_array[0].last_read; /* wsprintf(pszFileText, "%d", dwOldUnit); SetDlgItemText(hwnd, IDC_OLD, pszFileText); sprintf(pszFileText, "%.2f", Debt); SetDlgItemText(hwnd, IDC_DEBT, pszFileText); */ //dwTempValue = atol (pszFileText); } } } CloseHandle(hFile); bSuccess = TRUE; } else bSuccess = FALSE; return bSuccess; } // Save current data to file BOOL SaveFile(HWND hwnd, LPCTSTR pszFileName) { HANDLE hFile; //DWORD FileArray[4]; BOOL bSuccess = FALSE; hFile = CreateFile(pszFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if(hFile != INVALID_HANDLE_VALUE) { if(p_array != NULL) { DWORD dwWritten; p_array[0].last_read = total_acc; WriteFile(hFile, p_array, sizeof(p_array), &dwWritten, NULL); } CloseHandle(hFile); bSuccess = TRUE; } return bSuccess; } edited:additional info,aku tak guna generic C functions utk write/load file.. but functions from win32 API Edited September 18, 2005 by zeph Quote Share this post Link to post Share on other sites
fynaz 0 Report post Posted September 19, 2005 tak..mmg copy paste je..sebenarrnye panjang lagi ni.. oh,ye..lupe lak actually tktau gak camane nk save data dlm file..lom wat lagi..humm..ni pakai c++..sowi..tk phm sgtla kalau pakai c..mesti awak copy paste jer ni.. sebab aku tak nampak pulak function utk store record tu dalam file seperti .dat or anythingbtw, utk tidak menghampakan dan agar tak cluecless lagi, ni code aku buat utk project bagi subject c programming dulu2 BOOL LoadFile(HWND hwnd, LPCTSTR pszFileName) { HANDLE hFile; BOOL bSuccess; hFile = CreateFile(pszFileName, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if(hFile != INVALID_HANDLE_VALUE) { DWORD dwFileSize; dwFileSize = GetFileSize(hFile, NULL); if(dwFileSize != 0xFFFFFFFF) { if(p_array != NULL) { DWORD dwRead; if(ReadFile(hFile, p_array, dwFileSize, &dwRead, NULL)) { total_acc = p_array[0].last_read; /* wsprintf(pszFileText, "%d", dwOldUnit); SetDlgItemText(hwnd, IDC_OLD, pszFileText); sprintf(pszFileText, "%.2f", Debt); SetDlgItemText(hwnd, IDC_DEBT, pszFileText); */ //dwTempValue = atol (pszFileText); } } } CloseHandle(hFile); bSuccess = TRUE; } else bSuccess = FALSE; return bSuccess; } // Save current data to file BOOL SaveFile(HWND hwnd, LPCTSTR pszFileName) { HANDLE hFile; //DWORD FileArray[4]; BOOL bSuccess = FALSE; hFile = CreateFile(pszFileName, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); if(hFile != INVALID_HANDLE_VALUE) { if(p_array != NULL) { DWORD dwWritten; p_array[0].last_read = total_acc; WriteFile(hFile, p_array, sizeof(p_array), &dwWritten, NULL); } CloseHandle(hFile); bSuccess = TRUE; } return bSuccess; } edited:additional info,aku tak guna generic C functions utk write/load file.. but functions from win32 API← Quote Share this post Link to post Share on other sites
fynaz 0 Report post Posted September 19, 2005 wah..tolong..tk phm la...huargh.. ANYONE yg sudi tlg please..........tak..mmg copy paste je..sebenarrnye panjang lagi ni.. oh,ye..lupe lak actually tktau gak camane nk save data dlm file..lom wat lagi..humm..ni pakai c++..sowi..tk phm sgtla kalau pakai c..← Quote Share this post Link to post Share on other sites
da^hype 0 Report post Posted September 22, 2005 http://www.codedb.org/submit/view.php?id=161It doesn't do exactly what you want. but the general idea and functionality is the same. Hope this helps. Quote Share this post Link to post Share on other sites
fynaz 0 Report post Posted September 23, 2005 http://www.codedb.org/submit/view.php?id=161It doesn't do exactly what you want. but the general idea and functionality is the same. Hope this helps.←emm..is it??i try to modify it by using the filing system..but..it seems doesn't work though..*sigh* ..nway,thankz 4 ur help..btw,i alreay submitted my paperwork...hehe..it can run properly but the only problem was i'm not using the filing system..ekeke...humm..it's gonna be a long journey to learn the "files management".. Quote Share this post Link to post Share on other sites
da^hype 0 Report post Posted September 23, 2005 (edited) rasanya mmg jln code aku tu. apa yg kau ubah? well if you have problems on file i/o just ask here. i would have replied earlier, but been real bz with work. srry Edited September 23, 2005 by da^hype Quote Share this post Link to post Share on other sites