Where to place file in order to read?

前端 未结 4 492
小鲜肉
小鲜肉 2021-01-20 01:20

Hey, where do I place a text file that I\'m trying to read using fstream? In this tutorial, http://www.gamedev.net/reference/articles/article1127.asp, they say

ifstr

4条回答
  •  逝去的感伤
    2021-01-20 02:19

    I would still say specify path instead of relying on current working directory (although for some reason it didn't work for you before).

    Try that: ifstream fin("C:/MyDir1/MyDir2/input.txt");

    or that: ifstream fin("C:\MyDir1\MyDir2\input.txt");

    Also make sure that your program (account it runs under) has at least Read permission for this file.

提交回复
热议问题