Hi All,
I am getting an warning "No Newline at the end of the file". I have tried to print only "Hello" instead of the main program then also I am getting the warning for the single line program. Can any body advise on this.
Thanks,
Printable View
Hi All,
I am getting an warning "No Newline at the end of the file". I have tried to print only "Hello" instead of the main program then also I am getting the warning for the single line program. Can any body advise on this.
Thanks,
What's your best guess on what's causing the warning?
It is standard for all text files in UNIX or Linux to always have a newline (Empty line) at the end of the file. Many utilities have problems with text files without the final newline.
Most if not all Linux & UNIX editors will insure a final newline by default, when saving the file. There may be an option in your Windows editor, or IDE to insure this.
I have never tested this with a C compiler, but not surprised.
It's not an empty line at the end of the file, as a lot of people seem to believe. It's a newline character at the end of each line. A text file with n lines has exactly n newline characters, so a text file with no lines has no newline characters. (That said, many text editors do display an empty line at the end of a proper text file, even though that line doesn't actually exist.)
(DOS/Windows sometimes treats the newline character sequence (CR LF) as a line separator, rather than a line terminator, which makes it impossible to distinguish between a file with zero lines of text and a file with one zero-length line of text. POSIX doesn't have that problem.)
Either way, the C and C++ standards require that all lines in a source file to end in a newline character(s). (I mention C++ because the source file in OP's screenshot is Untitled6.cpp, which indicates a C++ source file.)