Home > Software engineering >  I've got three days, can't find out the mistakes, please help!
I've got three days, can't find out the mistakes, please help!

Time:10-29

Sincerely ask for help! Do is the string matching in Chinese word segmentation technology,
The front part of the code used in c + + link to access the code to compile without fault, a run is an error "abnormal program termination", there is nothing wrong with the code behind the debugged separately,

 # include & lt; Afx. H>//cstrings 
#include
#include
using namespace std;
//access2007
#include
# import "C: \ Program Files \ Common Files \ System \ ado \ msado15 DLL" rename (" EOF ", "adoEOF")
Using the namespace ADODB library;
Using STD: : ofstream;

/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- to define a CMyDictionary -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
The class CMyDictionary
{
CDaoDatabase * pDatabase;//database class pointer
CDaoRecordset * pWords;
CDaoTableDef * pWordsDef;
Public:
CMyDictionary ();
~ CMyDictionary ();
Long GetFreq cstrings (w);
};

CMyDictionary Dict.

/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- CMyDictionary constructor -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - */
CMyDictionary: : CMyDictionary ()
{
PDatabase=new CDaoDatabase;
PDatabase - & gt; Open (" d: \ \ myfile \ \ mydict accdb ");////open the database -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
PWordsDef=new CDaoTableDef (pDatabase);
PWordsDef - & gt; Open (" words ");//open the word table structure, word table name as a parameter
PWords=new CDaoRecordset (pDatabase);
PWords - & gt; Open (pWordsDef);//open the word table record set, pointer as the argument list structure
}

/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- the destructor CMyDictionary -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - */
CMyDictionary: : ~ CMyDictionary ()
{
If (pWords)
{pWords - & gt; Close (); The delete pWords; }
If (pWordsDef)
{pWordsDef - & gt; Close (); The delete pWordsDef; }
If (pDatabase)
{pDatabase - & gt; Close (); The delete pDatabase; }
}

/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- look up words in a dictionary the word -- -- -- -- -- -- -- -- -- -- -- -- -- - */
Long CMyDictionary: : GetFreq cstrings (w)
{
COleVariant kw (w, VT_BSTRT), kf;
PWords - & gt; SetCurrentIndex (" word ");
If (pWords - & gt; Seek ("=", & amp; Kw))
{
return 1;//find the word in the dictionary
}
The else return - 1;//was not found in the dictionary the word
}

CodePudding user response:

 # include & lt; Afx. H>//cstrings 
#include
#include
using namespace std;
//access2007
#include
# import "C: \ Program Files \ Common Files \ System \ ado \ msado15 DLL" rename (" EOF ", "adoEOF")
Using the namespace ADODB library;
Using STD: : ofstream;

/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- to define a CMyDictionary -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- */
The class CMyDictionary
{
CDaoDatabase * pDatabase;//database class pointer
CDaoRecordset * pWords;
CDaoTableDef * pWordsDef;
Public:
CMyDictionary ();
~ CMyDictionary ();
Long GetFreq cstrings (w);
};

CMyDictionary Dict.

/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- CMyDictionary constructor -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - */
CMyDictionary: : CMyDictionary ()
{
PDatabase=new CDaoDatabase;
PDatabase - & gt; Open (" d: \ \ myfile \ \ mydict accdb ");////open the database -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
PWordsDef=new CDaoTableDef (pDatabase);
PWordsDef - & gt; Open (" words ");//open the word table structure, word table name as a parameter
PWords=new CDaoRecordset (pDatabase);
PWords - & gt; Open (pWordsDef);//open the word table record set, pointer as the argument list structure
}

/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- the destructor CMyDictionary -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- - */
CMyDictionary: : ~ CMyDictionary ()
{
If (pWords)
{pWords - & gt; Close (); The delete pWords; }
If (pWordsDef)
{pWordsDef - & gt; Close (); The delete pWordsDef; }
If (pDatabase)
{pDatabase - & gt; Close (); The delete pDatabase; }
}

/* -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- look up words in a dictionary the word -- -- -- -- -- -- -- -- -- -- -- -- -- - */
Long CMyDictionary: : GetFreq cstrings (w)
{
COleVariant kw (w, VT_BSTRT), kf;
PWords - & gt; SetCurrentIndex (" word ");
If (pWords - & gt; Seek ("=", & amp; Kw))
{
return 1;//find the word in the dictionary
}
The else return - 1;//was not found in the dictionary the word
}

CodePudding user response:

Do you play a few breakpoints, debugged and see the Debug mode, where execution fails?

CodePudding user response:

Try catch catch _com_error

CodePudding user response:

Track step by step, really not line, run, play a dialog box, see run where it went wrong...

CodePudding user response:

# import "C: \ Program Files \ Common Files \ System \ ado \ msado15 DLL" rename (" EOF ", "adoEOF")

XP and Windows 7/8/10 of the path is not the same ~ ~

CodePudding user response:

  • Related