warning:no newline at end of file

Please support our C advertiser: Programming Forums - DaniWeb Sister Site
Closed Thread

Join Date: Jul 2004
Posts: 3
Reputation: abd2 is an unknown quantity at this point 
Solved Threads: 0
abd2 abd2 is offline Offline
Newbie Poster

warning:no newline at end of file

 
2
  #1
Jul 10th, 2004
hi,
this is the code:
#include <stdio.h>
main()
{
int m1, m2, m3, m4, m5, per;

printf("Enter marks in five subjects\n");
scanf("%d%d%d%d%d",&m1,&m2,&m3,&m4,&m5);


per=(m1+m2+m3+m4+m5)/5;

if(per>=60)
printf("first division\n");

if((per>=50) && (per<60))
printf("second division\n");

if((per>=40) && (per<50))
printf("third division\n");

if(per<40)
printf("fail\n");

}

this is the output for:

[root@localhost lbin]# gcc -o division division.c
division.c:30:1: warning: no newline at end of file

The executable file division is runing successfully,just i want to know why there is the error 'no newline at the end of file' although i hit the <return> in the end of file 'after }' three times.
plz help me.




:-|
Quick reply to this message  
Join Date: Apr 2004
Posts: 4,461
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 254
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: warning:no newline at end of file

 
0
  #2
Jul 11th, 2004
Did you save it or did it automatically save after entering the 3 lines? [And next time, try to put your code between code tags ([code][/code]).]
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Quick reply to this message  
Join Date: Jul 2004
Posts: 17
Reputation: nufanvandal is an unknown quantity at this point 
Solved Threads: 0
nufanvandal nufanvandal is offline Offline
Newbie Poster

Re: warning:no newline at end of file

 
1
  #3
Jul 11th, 2004
I ran your program through my gcc compiler, i did not get any errors. so whats the problem? :cheesy:
Quick reply to this message  
Join Date: Mar 2004
Posts: 1,620
Reputation: kc0arf is a jewel in the rough kc0arf is a jewel in the rough kc0arf is a jewel in the rough 
Solved Threads: 51
Team Colleague
kc0arf kc0arf is offline Offline
Posting Virtuoso

Re: warning:no newline at end of file

 
1
  #4
Jul 12th, 2004
Hello,

I used the pico editor to cut your text, and paste them into my RedHat 9 box. Then closed the editor, and it compiled just fine.

Maybe you are using vi and left something in there. Or Emacs left something. I dunno. Try cat division.c and see if you see any junk in the file.

I do think, however, it is poor program design on two occasions:

* You are using an integer for the division. per = (M+M+M) / 5 What happens if I enter in decimal numbers?

* You are asking for input on one line. Will the computer accept typo corrections? I would input them one line at a time, so that if I do typo, I can correct it without deleting too much. You also do not check to make sure I enter in 5 values. What happens if I only put in four?

(I have tested these conditions. You should too).

Enjoy!

Christian
Quick reply to this message  
Join Date: Jul 2004
Posts: 17
Reputation: nufanvandal is an unknown quantity at this point 
Solved Threads: 0
nufanvandal nufanvandal is offline Offline
Newbie Poster

Re: warning:no newline at end of file

 
0
  #5
Jul 14th, 2004
indeed :mrgreen:
Quick reply to this message  
Join Date: Jun 2007
Posts: 1
Reputation: joshD is an unknown quantity at this point 
Solved Threads: 0
joshD joshD is offline Offline
Newbie Poster

Re: warning:no newline at end of file

 
1
  #6
Jun 20th, 2007
I realize that this thread is 2 years old, but it is the top search result for this error message, so maybe I will help a fellow newb.

If you are using the dev c++ enviroment,as I am, and probably other enviroments. The Error is caused by not hitting enter after the last line of code.
Quick reply to this message  
Join Date: Oct 2004
Posts: 4,141
Reputation: vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice vegaseat is just really nice 
Solved Threads: 947
Moderator
vegaseat's Avatar
vegaseat vegaseat is offline Offline
DaniWeb's Hypocrite

Re: warning:no newline at end of file

 
0
  #7
Jun 20th, 2007
Somewhere in the C compiler details it states that the code has to finish with a newline. Dev-Cpp's GNU compiler and some other compilers give a warning, not an error. Many IDEs put the new line in automatically.
Last edited by vegaseat; Jun 20th, 2007 at 9:36 pm.
May 'the Google' be with you!
Quick reply to this message  
Join Date: Feb 2007
Posts: 539
Reputation: thekashyap will become famous soon enough thekashyap will become famous soon enough 
Solved Threads: 50
thekashyap's Avatar
thekashyap thekashyap is offline Offline
Posting Pro

Re: warning:no newline at end of file

 
0
  #8
Jun 21st, 2007
Couldn't help but notice that unless there is some bug in daniweb.com this is most read thread I've seen so far.. ! 17,751 times..
Are you Agile.. ?
Quick reply to this message  
Join Date: Aug 2005
Posts: 15,662
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1501
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: warning:no newline at end of file

 
0
  #9
Jun 21st, 2007
Originally Posted by thekashyap View Post
Couldn't help but notice that unless there is some bug in daniweb.com this is most read thread I've seen so far.. ! 17,751 times..
you need to report that to Dani
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Quick reply to this message  
Join Date: Feb 2007
Posts: 539
Reputation: thekashyap will become famous soon enough thekashyap will become famous soon enough 
Solved Threads: 50
thekashyap's Avatar
thekashyap thekashyap is offline Offline
Posting Pro

Re: warning:no newline at end of file

 
0
  #10
Jun 22nd, 2007
Originally Posted by Ancient Dragon View Post
you need to report that to Dani
I donno where/how to tell her.. You're the moderator.. I understand you guys have some forums by yourselves..
Are you Agile.. ?
Quick reply to this message  
Closed Thread

Message:



Similar Threads
Other Threads in the C Forum


Views: 56672 | Replies: 18
Thread Tools Search this Thread



Tag cloud for C
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC