How do I set file permissions when opening a file in C++?
问题 In C++, I want to open a file and set its permission, but I failed. Below is my program: string filename="test.cnf"; ofstream ofile; ofile.open(filename.c_str(),O_RDONLY); ofile.close() But I get the following error: error: invalid conversion from 'int' to 'std::_Ios_Openmode' error: initializing argument 2 of 'void std::basic_ofstream<_CharT, _Traits>::open(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits<char>]' How to set the permission of the file to such