Is a blank at the end of a C file a better style than a newline atthe end of the file or is it bette

Discussion in 'C Programming' started by Jimmy, Sep 9, 2011.

  1. Jimmy

    Jimmy Guest

    Hello everyone!

    As the subject says. The reason for my question is that emacs always
    suggest me to put a newline at the end of the C file if I forget to do
    it. Why?

    Sincerely,
    Jimmy
     
    Jimmy, Sep 9, 2011
    #1
    1. Advertising

  2. Jimmy

    James Kuyper Guest

    Re: Is a blank at the end of a C file a better style than a newlineat the end of the file or is it better to place none?

    On 09/09/2011 04:46 PM, Jimmy wrote:
    > Hello everyone!


    You should always put your question in the body of the message. The
    subject line should only be a summary (and it should be a shorter
    summary than this one is.

    > As the subject says. The reason for my question is that emacs always
    > suggest me to put a newline at the end of the C file if I forget to do
    > it. Why?


    Because there are systems where the absence of such a newline will cause
    your program to not be processed properly. The C standard has been
    written to allow such systems to be fully conforming.
     
    James Kuyper, Sep 9, 2011
    #2
    1. Advertising

  3. Jimmy

    Joe Pfeiffer Guest

    Re: Is a blank at the end of a C file a better style than a newline at the end of the file or is it better to place none?

    Jimmy <> writes:

    > Hello everyone!
    >
    > As the subject says. The reason for my question is that emacs always
    > suggest me to put a newline at the end of the C file if I forget to do
    > it. Why?


    It makes the same suggestion for every sort of text file I've ever had
    occasion to notice it on. There are lots of programs accepting text
    input that assume every line of text ends with a newline, and which will
    misbehave in various ways if that assumption is false (at one time
    decades ago, the sh shell was one of those programs -- and if the last
    line of a shell script didn't end with a newline, that last command
    wasn't executed).
     
    Joe Pfeiffer, Sep 9, 2011
    #3
  4. Re: Is a blank at the end of a C file a better style than a newlineat the end of the file or is it better to place none?

    Jimmy wrote:
    >
    > As the subject says.


    I can't see all the subject, so I'll guess. Much better to put the
    question in the message so people are more easily able to read and
    comment on it.

    > The reason for my question is that emacs always
    > suggest me to put a newline at the end of the C file if I forget to do
    > it. Why?


    My best guess is that it's because every line in a text file
    conventionally ends in a newline character; I've had other editors give
    similar warnings on other types of text file.

    If it's intelligent enough to understand that this particular file is
    meant to be a C source file, then it may be because the C language
    requires a non-empty source file to end with a non-escaped newline
    character.
     
    J. J. Farrell, Sep 9, 2011
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Peter Bencsik
    Replies:
    2
    Views:
    878
  2. js
    Replies:
    2
    Views:
    416
  3. ÖܼÃÊÇĸÀÏÊó
    Replies:
    3
    Views:
    1,844
    Benjamin
    Oct 29, 2008
  4. Jimmy
    Replies:
    13
    Views:
    671
    Peter Nilsson
    Sep 21, 2011
  5. Cristina
    Replies:
    2
    Views:
    146
    Nate St.Germain
    Jul 16, 2010
Loading...

Share This Page