c++ - 程序说词典不存在

标签 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;
    }

}

检查单词拼写的函数使用相同的字典变量,并且工作正常。我很困惑。我做错了什么?

最佳答案

你确定你使用的路径正确吗?
喜欢:

C:\\Folder\\folder\...

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

关于c++ - 程序说词典不存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16109404/

相关文章:

c++ - Borland C++ 2009 中的 OpenCV

c++ - 在 C++11 中,将引用/指针返回到 std::string 中某个位置的最高效方法是什么?

scala - 在Scala中处理文件时出现java.nio.BufferUnderflowException

c - 如何从对象或静态库创建共享库

ios - 如何创建静态库并可以在 ios 中的任何项目上添加 .a 文件

c++ - CMake:将第三方库链接到项目库

C++ 未定义对链接函数的引用

c++ - 如何在 VS 2012 中查看 C++ 链接命令

Java程序文件句柄

c++ - 如何在 C++ 中自动打开输入文件?