Having trouble with fstream in Xcode

后端 未结 2 1478
渐次进展
渐次进展 2021-01-25 03:48

I\'m having trouble validating the existence of REGISTER.txt for input purposes in a function (see below). My understanding is that if the file doesn\'t exist, then the file won

相关标签:
2条回答
  • 2021-01-25 04:31

    REGISTER.txt is in the same directory as my .cpp file

    REGISTER.txt needs to be in the same directory as the binary (build/Release or elsewhere depending on your build settings)

    0 讨论(0)
  • 2021-01-25 04:31

    Normally it would be the directory where your program lives. If you want to make sure, use _getcwd to get the current directory or just include the parent directory.

    char *_getcwd( char *buffer, int maxlen );

    However, you should try not to use the full path for the reason it might not be the same when you run your program on another computer.

    0 讨论(0)
提交回复
热议问题