CLion C++ can't read/open .txt file in project directory

后端 未结 6 1113
半阙折子戏
半阙折子戏 2020-12-09 17:25

I have a .txt file in my project directory that I made and populated with data.

directory structure looks like:

/Users/asd/ClionProjects/ProjectWithT         


        
6条回答
  •  盖世英雄少女心
    2020-12-09 17:46

    if inputFile.is_open() always returns false, inputFile.open("twoday.txt"); is not opening the file correctly, presumably because it can't find "twoday.txt"

    Try setting an explicit path like "c:/path/twoday.txt" or "/path/twoday.txt" if you're using Linux. You could also try writing a file instead to see where it shows up, or something more exotic to return the current path.

提交回复
热议问题