943,524 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 71940
  • C RSS
You are currently viewing page 1 of this multi-page discussion thread
Jul 10th, 2004
2

warning:no newline at end of file

Expand Post »
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.




:-|
Similar Threads
Reputation Points: 13
Solved Threads: 0
Newbie Poster
abd2 is offline Offline
3 posts
since Jul 2004
Jul 11th, 2004
0

Re: warning:no newline at end of file

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]).]
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Jul 11th, 2004
1

Re: warning:no newline at end of file

I ran your program through my gcc compiler, i did not get any errors. so whats the problem? :cheesy:
Reputation Points: 11
Solved Threads: 0
Newbie Poster
nufanvandal is offline Offline
18 posts
since Jul 2004
Jul 12th, 2004
1

Re: warning:no newline at end of file

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
Team Colleague
Reputation Points: 121
Solved Threads: 57
Posting Virtuoso
kc0arf is offline Offline
1,629 posts
since Mar 2004
Jul 14th, 2004
0

Re: warning:no newline at end of file

indeed :mrgreen:
Reputation Points: 11
Solved Threads: 0
Newbie Poster
nufanvandal is offline Offline
18 posts
since Jul 2004
Jun 20th, 2007
1

Re: warning:no newline at end of file

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.
Reputation Points: 32
Solved Threads: 0
Newbie Poster
joshD is offline Offline
1 posts
since Jun 2007
Jun 20th, 2007
0

Re: warning:no newline at end of file

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.
Moderator
Reputation Points: 1333
Solved Threads: 1403
DaniWeb's Hypocrite
vegaseat is offline Offline
5,792 posts
since Oct 2004
Jun 21st, 2007
0

Re: warning:no newline at end of file

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..
Reputation Points: 254
Solved Threads: 74
Practically a Posting Shark
thekashyap is offline Offline
804 posts
since Feb 2007
Jun 21st, 2007
0

Re: warning:no newline at end of file

Click to Expand / Collapse  Quote originally posted by thekashyap ...
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
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,945 posts
since Aug 2005
Jun 22nd, 2007
0

Re: warning:no newline at end of file

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..
Reputation Points: 254
Solved Threads: 74
Practically a Posting Shark
thekashyap is offline Offline
804 posts
since Feb 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
This thread is currently closed and is not accepting any new replies.
Previous Thread in C Forum Timeline: Structures in functions.
Next Thread in C Forum Timeline: Passing an array of structs by reference?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC