I just started to learn C and I am reading a book about it. Unfortunately, it is a bit old and it is using c89. I looked around the internet but I guess c89 was used 10 years ago no one wrote anything about it. I want to compile my code in c89 but from what I understand visual code doesn't have a c89 compiler. Is there any c89 compiler I can use?
-
1why bother? Why cant you code to a newer version? – OldProgrammer Apr 28 '21 at 17:43
-
1Most C89 code can be compiled perfectly fine by a compiler that only supports newer versions. Is there a reason you want to stick with this old version? – G. Sliepen Apr 28 '21 at 17:44
-
5C89 code should run in a newer compiler. The problem is only going backwards -- if you have a C89 compiler, it won't support new features that were added later. – Barmar Apr 28 '21 at 17:44
-
1@Zer0day You can use for example the online compiler at www.ideone.com – Vlad from Moscow Apr 28 '21 at 17:48
-
3`I guess c89 was used 10 years ago` The "89" in "C89" stands for year 1989. – dxiv Apr 28 '21 at 17:48
-
Rather than learn C89 from 32 years ago and 4 versions back, C11, C99, C94, C89, consider C17. – chux - Reinstate Monica Apr 28 '21 at 17:50
-
I know it's old but I have a friend who writes c for a very long time and they told me that the msvc c versions are so new and very bad. It's not what I say don't get me wrong maybe it's not but that's what I heard. I want to start with c89. Is there a way I can compile with c89. I know the new does support it but I just want to start out with c89. So it would be very helpful if you can suggest any c89 compiler. – Zer0day Apr 28 '21 at 17:52
-
@chux-ReinstateMonica ... [c20/21](http://www.open-std.org/jtc1/sc22/wg14/www/docs/n2596.pdf)? – pmg Apr 28 '21 at 17:53
-
1For learning C you better stay away from msvc all together. Use `gcc` and stick to newer standards. – Eugene Sh. Apr 28 '21 at 17:54
-
What's the name of the book? – klutt Apr 28 '21 at 17:57
-
Your friend may have overstated the problems with modern C; but is likely correct that sticking to c89 before working with the more indulgent mutations is worthwhile. Both gcc and clang support --std=c89, which will restrict the compiler to the core language. You might want to skip the dos / vc environs; get a linux / linux vm. – mevets Apr 28 '21 at 17:58
-
My `gcc` (version 9.3.0-r2) happily accepts `--std=c89` as command line option. Not sure if that turns off newer features, but I assume older features should be available for all you thrill seeking `gets` aficionados out there. – HAL9000 Apr 28 '21 at 17:58
-
@pmg Any day now. – chux - Reinstate Monica Apr 28 '21 at 18:09
2 Answers
Yes, there are C89 compilers available. You can for instance use gcc -std=c89 -pedantic
to get a compiler very close to the C89 standard.
If the book is about C89, it is most likely not very good. Partly because it is about an ancient standard that does not have modern features that really makes it much easier to code C. But also because if it's about C89, it's likely very old and predates modern C design ṕatters in general.
I recommend treating that book as a some kind of historical relic. Read it for fun, but don't use it to learn coding. If you want to learn modern C, then Modern C is a good choice. It's not aimed at total beginners, but it teaches much better C code than any C89 book.
You mentioned in comments that the book is "The C Programming language". I would not recommend it for tutoring.

- 30,332
- 17
- 55
- 95
-
1
-
It's called The C Programming language. It's realized in 1978. I am actually not sure if it's c89 but since it's realized a very long time ago I think it's about that version. – Zer0day Apr 28 '21 at 18:03
-
@Zer0day That sounds like the Kernighan/Ritchie book people like me learned C from *prior* to the first (1989) ANSI/ISO C standard. *Not* recommended. – njuffa Apr 28 '21 at 18:05
-
-
I don't know. A lot of people have recommended that book so I think it won't hurt to give it a try. Even though it's old I don't think it would be hard to learn the new standard once you have a good understanding of the basics in C. – Zer0day Apr 28 '21 at 18:10
-
-
@Zer0day If you want to learn bad habits, I guess I cannot stop you from doing that. :) – klutt Apr 28 '21 at 18:14
-
@Zer0day I'm curious, because it could be the case that it was the book "Let us C" which is completely garbage. It's a tragic comedy for anyone who knows C and a catastrophy for beginners. When you mentioned that it was the much better book "The C programming language" I wanted to make sure that it was at least not the 1st edition. Learning from 2nd is not very good, but not terribly bad. And since 2nd is freely available online, there's absolutely no reason to use 1st. – klutt Apr 28 '21 at 18:22
-
2@Zer0day Np. But what I'm trying to say is that there's absolutely no reason to "start with c89 to learn the basics". You don't gain anything from learning an early version first. It would be like you want to learn to speak Chinese, but starting with how they spoke centuries ago. It would make more sense to start with learning how they speak today, and THEN learn how they spoke historically, but then with a historical perspective. Many C89 things are considered very bad practice today. – klutt Apr 28 '21 at 18:37
-
Yeah I know I got it. I just started out the book and C so I will just try it out. I am just looking if it's useful or not. It's not my full go-to book. I will look for other books too. Thanks. – Zer0day Apr 28 '21 at 18:45
Just about the only thing that is present in C89 and missing in newer C standards is the gets
function, which you should never use anyway.

- 20,656
- 7
- 53
- 85