Thread: Help Required

  1. #1
    Registered User
    Join Date
    Feb 2020
    Posts
    1

    Help Required

    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,
    Attached Images Attached Images Help Required-capture-png 

  2. #2
    misoturbutc Hodor's Avatar
    Join Date
    Nov 2013
    Posts
    1,791
    What's your best guess on what's causing the warning?

  3. #3
    Registered User rstanley's Avatar
    Join Date
    Jun 2014
    Location
    New York, NY
    Posts
    1,106
    Quote Originally Posted by sr0099 View Post
    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,
    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.

  4. #4
    Registered User
    Join Date
    May 2012
    Location
    Arizona, USA
    Posts
    945
    Quote Originally Posted by rstanley View Post
    It is standard for all text files in UNIX or Linux to always have a newline (Empty line) at the end of the file.
    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.)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. l value required
    By anil_ in forum C++ Programming
    Replies: 16
    Last Post: 10-06-2011, 01:00 PM
  2. Help Required
    By Fatima Rizwan in forum C++ Programming
    Replies: 4
    Last Post: 11-29-2009, 07:49 AM
  3. C help required
    By rmc in forum C Programming
    Replies: 18
    Last Post: 03-29-2009, 01:13 PM
  4. Little help required...
    By Ninestar in forum C Programming
    Replies: 5
    Last Post: 03-17-2006, 05:32 PM
  5. little help required
    By Lynux-Penguin in forum C Programming
    Replies: 4
    Last Post: 04-27-2002, 01:34 PM

Tags for this Thread