Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > Is a blank at the end of a C file a better style than a newline atthe end of the file or is it better to place none?

Reply
Thread Tools

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

 
 
Jimmy
Guest
Posts: n/a
 
      09-09-2011
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
 
Reply With Quote
 
 
 
 
James Kuyper
Guest
Posts: n/a
 
      09-09-2011
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.
 
Reply With Quote
 
 
 
 
Joe Pfeiffer
Guest
Posts: n/a
 
      09-09-2011
Jimmy <(E-Mail Removed)> 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).
 
Reply With Quote
 
J. J. Farrell
Guest
Posts: n/a
 
      09-09-2011
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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Is a blank at the end of a C file a better style than a newline atthe end of the file or is it better to place none? Jimmy C Programming 13 09-21-2011 12:17 AM
farming automation [parallel testing on multipe remote machines atthe same time] Cristina Ruby 2 07-16-2010 02:52 AM
[Python 2.6] print_function and unicode_literals cannot be used atthe same time? ܼĸ Python 3 10-29-2008 03:07 AM
file.read() returns an emtpy even if its currenet position is not atthe end js Python 2 04-22-2007 11:18 PM
Is splint really better than lint? Is there a better tool than splint? Peter Bencsik C Programming 2 09-21-2006 10:02 PM



Advertisments