title: Why is my functioning giving me a "expected primary-expression before '}' token" while using a goto?
body: <p>My function is giving me  "expected primary-expression before '}' token" while using a goto and I don't know why.</p>
  
  <p>This code worked as-is in main before I put it into a function.</p>
  
  <p>It works when I replace the 'goto' with 'break', but I need to know why this is.</p>
  
  <pre><code>void fileInputLoop(ifstream&amp; inputFile){
      do{
  
          cout &lt;&lt; "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 &lt;&lt; "File is not available." &lt;&lt; endl;
              }else{
                  // FILE IS OPEN, DO SOMETHING WITH IT
                  ReadData(inputFile);
                  inputFile.close();
              }
          }
          // If a second++ file is read in, the previous file will be set accordingly
          // This is to track if a duplicate is from the same file or a new file
          previousFileName = fileName;
  
      }while(true);
      skip_data_input_loop:
  }
  </code></pre>