program nt responding--error
-
i wrote the following: void CText_dialogDlg::OnSearch() { CString buffer; FILE *stream; char target[80],etchant[80],conc[300]; char name[80]; int temp; int m_itemp; float etchrate; // float m_fetchrate; CString name_str; CString eof = "EOF"; CString m_strTarget; CString m_strConc; CString m_strEtchant; CString searchkey; stream = fopen( "e:\\fyp_2003\\database.txt", "r" ); searchkey=m_strkey; do { fscanf( stream, "%s", name ); fscanf( stream, "%s", target ); //fscanf( stream, "%s", process ); fscanf( stream, "%s", etchant); fscanf( stream, "%s", conc); fscanf( stream, "%d", &temp ); fscanf( stream, "%f", &etchrate ); name_str = name; }while (name_str != searchkey); /* Output data read: */ CString str; str.Format("%s %s %s %s %d %f",name,target,etchant,conc,temp,etchrate); m_dialog_etch.m_strTarget = target; //m_dialog_etch.m_str_process = process; m_dialog_etch.m_strEtchant = etchant; m_dialog_etch.m_itemp = temp; m_dialog_etch.m_fetchrate = etchrate; m_dialog_etch.m_strConc = conc; UpdateData(FALSE); m_dialog_etch.DoModal(); fclose( stream ); } but my dialog_etch din appear, instead the program hanged. i have 2 dialogs, dialog1 and dialog_etch, when user key in the edit box, my dialog etch will retrieve the info from a txtfile.
-
i wrote the following: void CText_dialogDlg::OnSearch() { CString buffer; FILE *stream; char target[80],etchant[80],conc[300]; char name[80]; int temp; int m_itemp; float etchrate; // float m_fetchrate; CString name_str; CString eof = "EOF"; CString m_strTarget; CString m_strConc; CString m_strEtchant; CString searchkey; stream = fopen( "e:\\fyp_2003\\database.txt", "r" ); searchkey=m_strkey; do { fscanf( stream, "%s", name ); fscanf( stream, "%s", target ); //fscanf( stream, "%s", process ); fscanf( stream, "%s", etchant); fscanf( stream, "%s", conc); fscanf( stream, "%d", &temp ); fscanf( stream, "%f", &etchrate ); name_str = name; }while (name_str != searchkey); /* Output data read: */ CString str; str.Format("%s %s %s %s %d %f",name,target,etchant,conc,temp,etchrate); m_dialog_etch.m_strTarget = target; //m_dialog_etch.m_str_process = process; m_dialog_etch.m_strEtchant = etchant; m_dialog_etch.m_itemp = temp; m_dialog_etch.m_fetchrate = etchrate; m_dialog_etch.m_strConc = conc; UpdateData(FALSE); m_dialog_etch.DoModal(); fclose( stream ); } but my dialog_etch din appear, instead the program hanged. i have 2 dialogs, dialog1 and dialog_etch, when user key in the edit box, my dialog etch will retrieve the info from a txtfile.
-
i wrote the following: void CText_dialogDlg::OnSearch() { CString buffer; FILE *stream; char target[80],etchant[80],conc[300]; char name[80]; int temp; int m_itemp; float etchrate; // float m_fetchrate; CString name_str; CString eof = "EOF"; CString m_strTarget; CString m_strConc; CString m_strEtchant; CString searchkey; stream = fopen( "e:\\fyp_2003\\database.txt", "r" ); searchkey=m_strkey; do { fscanf( stream, "%s", name ); fscanf( stream, "%s", target ); //fscanf( stream, "%s", process ); fscanf( stream, "%s", etchant); fscanf( stream, "%s", conc); fscanf( stream, "%d", &temp ); fscanf( stream, "%f", &etchrate ); name_str = name; }while (name_str != searchkey); /* Output data read: */ CString str; str.Format("%s %s %s %s %d %f",name,target,etchant,conc,temp,etchrate); m_dialog_etch.m_strTarget = target; //m_dialog_etch.m_str_process = process; m_dialog_etch.m_strEtchant = etchant; m_dialog_etch.m_itemp = temp; m_dialog_etch.m_fetchrate = etchrate; m_dialog_etch.m_strConc = conc; UpdateData(FALSE); m_dialog_etch.DoModal(); fclose( stream ); } but my dialog_etch din appear, instead the program hanged. i have 2 dialogs, dialog1 and dialog_etch, when user key in the edit box, my dialog etch will retrieve the info from a txtfile.
-
i wrote the following: void CText_dialogDlg::OnSearch() { CString buffer; FILE *stream; char target[80],etchant[80],conc[300]; char name[80]; int temp; int m_itemp; float etchrate; // float m_fetchrate; CString name_str; CString eof = "EOF"; CString m_strTarget; CString m_strConc; CString m_strEtchant; CString searchkey; stream = fopen( "e:\\fyp_2003\\database.txt", "r" ); searchkey=m_strkey; do { fscanf( stream, "%s", name ); fscanf( stream, "%s", target ); //fscanf( stream, "%s", process ); fscanf( stream, "%s", etchant); fscanf( stream, "%s", conc); fscanf( stream, "%d", &temp ); fscanf( stream, "%f", &etchrate ); name_str = name; }while (name_str != searchkey); /* Output data read: */ CString str; str.Format("%s %s %s %s %d %f",name,target,etchant,conc,temp,etchrate); m_dialog_etch.m_strTarget = target; //m_dialog_etch.m_str_process = process; m_dialog_etch.m_strEtchant = etchant; m_dialog_etch.m_itemp = temp; m_dialog_etch.m_fetchrate = etchrate; m_dialog_etch.m_strConc = conc; UpdateData(FALSE); m_dialog_etch.DoModal(); fclose( stream ); } but my dialog_etch din appear, instead the program hanged. i have 2 dialogs, dialog1 and dialog_etch, when user key in the edit box, my dialog etch will retrieve the info from a txtfile.
coda_x wrote:
do {
fscanf( stream, "%s", name );
fscanf( stream, "%s", target );
//fscanf( stream, "%s", process );
fscanf( stream, "%s", etchant);
fscanf( stream, "%s", conc);
fscanf( stream, "%d", &temp );
fscanf( stream, "%f", &etchrate );
name_str = name;}while (name_str != searchkey);
This loop is where your program is hanging. If you never read a value where
name_str==searchkey
, the loop will continue forever. Eventually you will reach the end of file, and thefscanf
functions will return errors.
Software Zen:
delete this;
-
coda_x wrote:
do {
fscanf( stream, "%s", name );
fscanf( stream, "%s", target );
//fscanf( stream, "%s", process );
fscanf( stream, "%s", etchant);
fscanf( stream, "%s", conc);
fscanf( stream, "%d", &temp );
fscanf( stream, "%f", &etchrate );
name_str = name;}while (name_str != searchkey);
This loop is where your program is hanging. If you never read a value where
name_str==searchkey
, the loop will continue forever. Eventually you will reach the end of file, and thefscanf
functions will return errors.
Software Zen:
delete this;
thanx! i solved that but now i have another problem, i use 2 if statements which contain different searchkey, so by right, my dialog_etch should display different information depending on the searchkey but it kept displaying the same info to mi...: if(strcmp(buffer,"Wet etch Al H3PO4") == 0) { CString search = "Wet1"; /* Read data back from file: */ do { fscanf( stream, "%s", name ); fscanf( stream, "%s", target ); fscanf( stream, "%s", process ); fscanf( stream, "%s", etchant); fscanf( stream, "%s", conc); fscanf( stream, "%d", &temp ); fscanf( stream, "%f", &etchrate ); name_str = name; }while (name_str != search); /* Output data read: */ CString str; str.Format("%s %s %s %s %s %d %f",name,target,process,etchant,conc,temp,etchrate); m_etchDlg.m_str_target = target; m_etchDlg.m_str_process = process; m_etchDlg.m_str_etchant = etchant; m_etchDlg.m_f_etchrate = etchrate; m_etchDlg.m_str_conc = conc; m_etchDlg.m_temp = temp; UpdateData(FALSE); m_etchDlg.DoModal(); fclose( stream ); } if(strcmp(buffer,"Wet etch Al H3PO4/HF") == 0) { CString search = "Wet2"; /* Read data back from file: */ do { fscanf( stream, "%s", name ); fscanf( stream, "%s", target ); fscanf( stream, "%s", process ); fscanf( stream, "%s", etchant); fscanf( stream, "%s", conc); fscanf( stream, "%d", &temp ); fscanf( stream, "%f", &etchrate ); name_str = name; }while (name_str != search); /* Output data read: */ CString str; str.Format("%s %s %s %s %s %d %f",name,target,process,etchant,conc,temp,etchrate); m_etchDlg.m_str_target = target; m_etchDlg.m_str_process = process; m_etchDlg.m_str_etchant = etchant; m_etchDlg.m_temp = temp; m_etchDlg.m_f_etchrate = etchrate; m_etchDlg.m_str_conc = conc; m_etchDlg.m_temp = temp; UpdateData(FALSE); m_etchDlg.DoModal(); fclose( stream ); } is there anything wrong with it?