Just picked up on c programming again and doing
Kernighan & Ritchie c programming
the question is this why does the program below
not work;
#include <stdio.h>
/* count characters in input: 1st version */
main()
{
    long nc;
    nc = 0;
   Â
    while(getchar() != EOF)
     ++nc;
     printf("%ld\n", nc);
   Â
}
typed as in book
to get it to work i have to do this:
#include <stdio.h>
/* count characters in input: 1st version */
int main(void)
{
    long nc;
    nc = 0;
    while(getchar() != EOF)
    {
     ++nc;
     printf("%ld\n", nc);
    }
    return 0;
}
could the answer be that the programs in the above book
was wrote for the old compilers a detailed explanation
would be most helpful thanks for your help
owe should this be the out put to the above program:
user@linux-1669:~/cpro/ch1./count
user
1
2
3
4
5
Kernighan & Ritchie c programming
the question is this why does the program below
not work;
#include <stdio.h>
/* count characters in input: 1st version */
main()
{
    long nc;
    nc = 0;
   Â
    while(getchar() != EOF)
     ++nc;
     printf("%ld\n", nc);
   Â
}
typed as in book
to get it to work i have to do this:
#include <stdio.h>
/* count characters in input: 1st version */
int main(void)
{
    long nc;
    nc = 0;
    while(getchar() != EOF)
    {
     ++nc;
     printf("%ld\n", nc);
    }
    return 0;
}
could the answer be that the programs in the above book
was wrote for the old compilers a detailed explanation
would be most helpful thanks for your help
#include <stdio.h>
>
/* count characters in input: 1st version */
>
int main(void)
{
    long nc;
>
    nc = 0;
>
    while(getchar() != EOF)
    {
     ++nc;
     printf("%ld\n", nc);
    }
    return 0;
}
>
>
/* count characters in input: 1st version */
>
int main(void)
{
    long nc;
>
    nc = 0;
>
    while(getchar() != EOF)
    {
     ++nc;
     printf("%ld\n", nc);
    }
    return 0;
}
>
user@linux-1669:~/cpro/ch1./count
user
1
2
3
4
5
Comment