相关疑难解决方法(0)

为什么我的功能在使用goto时给我一个"''''''''''''''''''''''''''''''

我的功能是在使用goto时给我"在'}'令牌之前预期的主要表达",我不知道为什么.

在我将它放入函数之前,这段代码按原样运行.

当我用'break'替换'goto'时它会起作用,但我需要知道为什么会这样.

void fileInputLoop(ifstream& inputFile){
    do{

        cout << "Enter data file name: ";
        getline(cin, fileName);
        previousFileName = fileName;
        // The user will press enter to exit data input 
        if(fileName == ""){
            // If no file name is entered, exit this input loop
            goto skip_data_input_loop;

        }else{
            // Check to see if input is an existing file
            inputFile.open(fileName);
            if(!inputFile.is_open()){
                cout << "File is not available." << endl;
            }else{
                // FILE IS OPEN, DO SOMETHING WITH IT
                ReadData(inputFile);
                inputFile.close();
            }
        }
        // …
Run Code Online (Sandbox Code Playgroud)

c++ debugging goto

0
推荐指数
1
解决办法
82
查看次数

标签 统计

c++ ×1

debugging ×1

goto ×1