How do I set the working directory to the “solution directory” in c++?

后端 未结 5 1192
生来不讨喜
生来不讨喜 2020-12-30 02:01

I want to set the current directory to the solution diretory/configuration name. How do I do that? Can I use the global variables somehow?

Edit: I am trying to read a

5条回答
  •  借酒劲吻你
    2020-12-30 02:17

    You can use the posix subsystem ( ) and access the functions

    _getcwd()/_wgetcwd() Gets the current working directory
    _chdir()/_wchdir() Sets the current working directory

    If you need your code to be cross platform, you can do the following:

    #ifdef _WIN32
    #  include 
    #  define getcwd _getcwd
    #  define chdir _chrdir
    #else
    #  include 
    #endif
    

    and use getcwd and chdir (w/o the leading underscore).

提交回复
热议问题