TreeFinger
June 12th, 2007, 11:01 AM
I am learning C++ out of a book meant for windows users. I know my code is right but I still get this error:
$ g++ add.cpp -o add.out
add.cpp:24:2: warning: no newline at end of file
The program will run fine and everything but this error just irks me ;)
Here is my source code if you would like to check it out:
// add.cpp
// Adds two user inputs
#include <iostream>
int main()
{
int integer1; // first number to be input by user
int integer2; // second number
int sum; // sum will be stored in this variable
std::cout << "Enter first integer\n"; // prompt
std::cin >> integer1; // assigns input to variable integer1
std::cout << "Enter second integer\n"; // second integer prompt
std::cin >> integer2; // assigns input to variable integer2
sum = integer1 + integer2; // assignment operator for sum
std::cout << "The sum of the two numbers is " << sum << "\n"; // Prints the sum of two numbers
return 0;
}
I have tried many different things including using std::endl; instead of the escape character but still no luck. Thanks for anyone who takes the time to answer this stupid and pointless question.
$ g++ add.cpp -o add.out
add.cpp:24:2: warning: no newline at end of file
The program will run fine and everything but this error just irks me ;)
Here is my source code if you would like to check it out:
// add.cpp
// Adds two user inputs
#include <iostream>
int main()
{
int integer1; // first number to be input by user
int integer2; // second number
int sum; // sum will be stored in this variable
std::cout << "Enter first integer\n"; // prompt
std::cin >> integer1; // assigns input to variable integer1
std::cout << "Enter second integer\n"; // second integer prompt
std::cin >> integer2; // assigns input to variable integer2
sum = integer1 + integer2; // assignment operator for sum
std::cout << "The sum of the two numbers is " << sum << "\n"; // Prints the sum of two numbers
return 0;
}
I have tried many different things including using std::endl; instead of the escape character but still no luck. Thanks for anyone who takes the time to answer this stupid and pointless question.