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.
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.
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):
#include <iostream>
#include <string>
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 << "Please eneter a number in the range of 1-10";
cin >> userNumber;
if(userNumber >= 1 and userNumber <=10){
okNumber = true;
}
else{
cout << "Incorrect number" << endl;
}
}
return userNumber;
}
void displayFactorial(int number){
string displayString = number + "! =";
int total;
for(int i = 0; i<=number; i++){
//displayString += "
}
cout << displayString;
}
// File ended the line above this (with a new line. This line added by Martin so it shows)
Any idea what could cause that warning if it's not the newline?