当我尝试使用此函数时,在两次返回时出现错误。如果我评论他们,我不会收到错误。这有什么理由不适用?尝试从函数返回std :: ifstream
std::ifstream bipgetConfigurationPath() {
char bipacfFilename[256], bipacfFullPath[512];
char *bipconfigPath;
char *bipdefaultConfigFile;
const char *bipdefaultConfigFileName;
bipdefaultConfigFile = "./Resources/plugins/Xsaitekpanels/D2B_config.txt";
bipdefaultConfigFileName = "D2B_config.txt";
XPLMGetNthAircraftModel(0, bipacfFilename, bipacfFullPath);
bipconfigPath = strstr(bipacfFullPath, bipacfFilename);
strncpy(bipconfigPath, bipdefaultConfigFileName, sizeof(bipacfFilename));
puts(bipacfFullPath);
// Check if ACF-specific configuration exists
std::ifstream bipcustomStream(bipacfFullPath);
if (bipcustomStream.good()) {
return bipcustomStream;
} else {
std::ifstream bipdefaultStream(bipdefaultConfigFile);
if (bipdefaultStream.good()) {
return bipdefaultStream;
}
}
}
感谢比尔
什么是错误? – loganfsmyth 2012-04-16 19:35:54
你有没有使用'std :: string'的原因? – AJG85 2012-04-16 19:39:51