Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. program nt responding--error

program nt responding--error

Scheduled Pinned Locked Moved C / C++ / MFC
databasehelp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    coda_x
    wrote on last edited by
    #1

    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.

    C P G 3 Replies Last reply
    0
    • C coda_x

      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.

      C Offline
      C Offline
      coda_x
      wrote on last edited by
      #2

      dialog1 is my text_dialogDlg

      1 Reply Last reply
      0
      • C coda_x

        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.

        P Offline
        P Offline
        PengFeidu
        wrote on last edited by
        #3

        hi! where is onsearch() called in? Maybe you have called this function in other procedure actived by EN_SETFOCUS message. dupengfei

        1 Reply Last reply
        0
        • C coda_x

          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.

          G Offline
          G Offline
          Gary R Wheeler
          wrote on last edited by
          #4

          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 the fscanf functions will return errors.


          Software Zen: delete this;

          C 1 Reply Last reply
          0
          • G Gary R Wheeler

            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 the fscanf functions will return errors.


            Software Zen: delete this;

            C Offline
            C Offline
            coda_x
            wrote on last edited by
            #5

            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?

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups