程序说字典不存在

时间:2013-04-19 16:35:02

标签: c++ file-io static-libraries spell-checking

我正在使用我的库libspellcheck编写一个拼写检查器。我有一个功能,可以在字典中添加一个单词。但是,它确实抛出一个异常,说字典不存在,当它确实存在时。你可以在这里找到关于pastebin的拼写检查代码:http://pastebin.com/1rCFAxDz。在libspellcheck库中添加单词的功能如下:

void add_word(char *dict, char *word)
{
    ofstream dictionary;
    dictionary.open(dict, ios::out | ios::app); 
    if (dictionary.is_open())
    {
            dictionary << word;
            dictionary << "\n";
            dictionary.close();
    }
    else
    {
        throw 1;
    }

}

检查单词拼写的功能使用相同的字典变量,并且工作正常。我很难过。我做错了什么?

1 个答案:

答案 0 :(得分:0)

您确定使用的是正确的路径吗? 像:

  

C:\\文件夹\\文件夹\ ...

有时您必须使用2 \\ instant of 1 \

相关问题