Re: What's wrong ?
- From: CBFalconer <cbfalconer@xxxxxxxxx>
- Date: Thu, 06 Mar 2008 09:44:49 -0500
"Daniel.C" wrote:
I just copied this code from my book with no modification :
#include <stdio.h>
/* count characters in input; 1st version */
main()
int main(void)
{
long nc;
nc = 0;
while (getchar() != EOF)
++nc;
printf("%ld\n", nc);
return 0;
}
There is no output, and no completion either. I tried adding a
"printf" at the end of the code, but it doesn't display.
Your book is obsolete and wrong. C99 requires the int in the
declaration of main, and the void for parameters is just good
practice. C99 will supply a default return value, but earlier
standards don't. Thus your code is wrong for any version.
If it doesn't work with the above simple changes, your compiler
system is fouled.
--
[mail]: Chuck F (cbfalconer at maineline dot net)
[page]: <http://cbfalconer.home.att.net>
Try the download section.
--
Posted via a free Usenet account from http://www.teranews.com
.
- Follow-Ups:
- Re: What's wrong ?
- From: Keith Thompson
- Re: What's wrong ?
- From: santosh
- Re: What's wrong ?
- References:
- What's wrong ?
- From: Daniel.C
- What's wrong ?
- Prev by Date: Re: Braces or not [Re: cat]
- Next by Date: Re: What's wrong ?
- Previous by thread: Re: What's wrong ?
- Next by thread: Re: What's wrong ?
- Index(es):
Relevant Pages
|