How to get the file separator symbol in standard C/C++ : / or \?

前端 未结 7 1446
攒了一身酷
攒了一身酷 2020-12-29 20:53

I would like to write a function :

inline char separator()
{
    /* SOMETHING */
}

that returns the file separator of the system in standar

7条回答
  •  盖世英雄少女心
    2020-12-29 21:01

    that can be something like this

    #if defined(WIN32) || defined(_WIN32) 
    #define PATH_SEPARATOR "\\" 
    #else 
    #define PATH_SEPARATOR "/" 
    #endif 
    

提交回复
热议问题