相关疑难解决方法(0)

Xcode STL C++ Debug编译错误

我有一些文件编写代码按预期工作,但在调试模式下输出错误,在Release中没有输出错误.

码:

#include <iostream>
#include <string>
#include <fstream>
#include <sstream>

using namespace std;

int main (int argc, char * const argv[]) {
    string cppfilename; 
    std::cout << "Please enter the filename to create: ";

    while ( cppfilename == "" ) {
        getline(cin, cppfilename);    // error occurs here
    }

    cppfilename += ".txt";
    ofstream fileout;
    fileout.open( cppfilename.c_str() );
    fileout << "Writing this to a file.\n"; 
    fileout.close();

    return 0;
}
Run Code Online (Sandbox Code Playgroud)

调试输出:

Please enter the filename to create: Running…
myfile
FileIO(5403) malloc: *** error for …
Run Code Online (Sandbox Code Playgroud)

c++ macos xcode runtime-error

4
推荐指数
2
解决办法
2768
查看次数

标签 统计

c++ ×1

macos ×1

runtime-error ×1

xcode ×1