How to use fstream objects with relative path?
问题 Do I always have to specify absolute path for objects instantiated from std::fstream class? In other words, is there a way to specify just relative path to them such as project path? 回答1: You can use relative paths as well. But they are relative to the environment you call your executable from. This is OS dependent but all the major systems behave more or less the same AFAIK. Windows example: // File structure: c:\folder\myprogram.exe c:\myfile.txt // Calling command from folder c:\folder >