Hello,
I have an old C book that starts most of its examples with main()
But, using Pelles C IDE, I need to change this line to int main(void)
1. Why is this?
Because your book is so old (or the author so ignorant) that it uses the old (as in outdated since
at least 1989, with the release of the first ANSI C standard, referred to as C89/C90)
"K&R" syntax. (K&R here refers to the original C authors,
Brian Kernighan and
Dennis Ritchie (+2012))
Pelle's C is compliant with
ANSI C (now C11), which fixed the old ambiguous syntax, and defaults to the ANSI C syntax.
2. Is there a way to write codes as in the book, using main()?
Yes, but is is highly discouraged to do so. Rather learn what the difference is (and why that change was made) and get used to the ANSI syntax and you will have much less problems, on almost any compiler, right from the start...
Thanks.
You're welcome...
Ralf