Note that there are some explanatory texts on larger screens.

plurals
  1. PO"No newline at end of file" warning, even after putting in a newline
    text
    copied!<p>I've been trying to learn C++ lately, and all has been going well until today. I'm trying to make a very simple application that basically just asks a user for a number and then displays the factorial of that number.</p> <p>When I try to compile the file in Cygwin (g++ factorial.cpp -o fact), I get the following warning "warning: no newline at end of file". Following the words of the warning, I added a newline at the end of the file and tried it again...with the exact same result. Whether I try one newline or twenty, it never seems to compile. </p> <p>I attached the simple, and still unfinished, file below (Except imagine there is a blank line at the end of it. This noob can't get it show up in code view): </p> <pre><code> #include &lt;iostream&gt; #include &lt;string&gt; using namespace std; int getInput(); void displayFactorial(int); int main() { int number = getInput(); displayFactorial(number); return 0; } int getInput() { int userNumber; bool okNumber; while(okNumber == false){ cout &lt;&lt; "Please eneter a number in the range of 1-10"; cin &gt;&gt; userNumber; if(userNumber &gt;= 1 and userNumber &lt;=10){ okNumber = true; } else{ cout &lt;&lt; "Incorrect number" &lt;&lt; endl; } } return userNumber; } void displayFactorial(int number){ string displayString = number + "! ="; int total; for(int i = 0; i&lt;=number; i++){ //displayString += " } cout &lt;&lt; displayString; } // File ended the line above this (with a new line. This line added by Martin so it shows) </code></pre> <p>Any idea what could cause that warning if it's not the newline?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload