Which compiler to use with K&R book?

I just started reading the C programming K&R book, it's an old book from 1988. So how am I gonna write programs with this book? Is there any software out there that I can use with this book?
Last edited on
Do you mean compilers?
http://www.cplusplus.com/forum/articles/7263/

Or something else?
closed account (1vRz3TCk)
Any compliant C compiler will do the job.

What OS are you using?

Edit:
A few additional books that you may find useful for you studies (check your library).
Practical C Programming by Steve Oualline
Mastering Algorithms with C by Kyle Loudon

and finally a good pocket reference (worth buying as it is cheap):
C Pocket Reference by Peter Prinz and Ulla Kirch-Prinz
Last edited on
I'm using W7 64-bit. Are there any compatible C compilers for W7?
closed account (1vRz3TCk)
Code::Blocks with MinGW ( http://www.codeblocks.org/ )
I have codeblocks
Last edited on
closed account (1vRz3TCk)
The last time I looked at it, it gave you the option of language on the console project, try reading the help files (I don't use Code::Blocks other than for small test files). Code::Blocks is an IDE, you can get it to use the C compiler from the MinGW tool chain it just needs configuring.

I tried using the code in the K&R book, but CB gave me 1 error, it seems I can't use the code from the book to write.
Last edited on
The book is old, I recommen getting a new one, otherwise you might be learning stuff that will have to unlearn.

Post the code you were trying to compile, it could be one of those cases.
i guess the compiler you needed just an up-to-date C compilers. the book's age doesn't matter (i guess, except there's a new syntax beyond it). or probably you can just download the tutorial from this site and just find yourself a VS 2008 express edition
#include <stdio.h>
main()
{
printf("hello, world\n");
}

This is the book's code. But the main.c in codeblocks which is also hello world is different.
Last edited on
closed account (1vRz3TCk)
Just tried that code in Code::Blocks and it worked fine.

File->new->project...
Selected Console application and clicked go
clicked next on the next page
Selected C and clicked next
gave it a Title and clicked next
left it on GNU GCC and clicked Finish

Opened main.c and replaced it with the code above and compiled and ran
btw it should be:
 
int main() //main() should return an int value 
it worked but i had 1 warning. So do I need to heed the warnings? Is it important for a program to have 0 warnings?
Last edited on
int main() is required in C++, but not in straight C.
closed account (1vRz3TCk)
it worked but i had 1 warning. So do I need to heed the warnings? Is it important for a program to have 0 warnings?
It depends on what the warning was. I would asume that it was to do with 'int implicate type specifier no longer assumed'.

In C, if you omit the type specifier, e.g. the int in int main(), the compiler will assume that it is an int. In C99 this assumption is no longer valid and will result in either a warning or an error depending on the compiler (a warning is more usual due to backward compatibility).

Generally having zero warnings is preferable but understanding warnings and deciding if they are a problem or not can be acceptable.
ok thx guys, I got what I need now.
Er, no one has yet said that K&R is not standard C. You need a compiler that can compile pre-ISO Standard C89.

The GCC is pretty good at handling K&R C, but there are some Incompatibilities:
http://gcc.gnu.org/onlinedocs/gcc/Incompatibilities.html

What exactly is giving you grief?

[edit] I came back and read this again and realized that I must have mixed thoughts on my first sentence, leaving it to say something I did not mean... I fixed it. ;-)
Last edited on
closed account (1vRz3TCk)
The 1988 second edition is standard, well the first printing is 'based on' but the second printing was updated to the published standard.
Topic archived. No new replies allowed.