2

My experience in C is mostly from second edition of The C Programming language which is a very old book. What has changed in C since it was released, what obsolete or deprecated functions should I avoid?

James McNellis
  • 348,265
  • 75
  • 913
  • 977
Iceland_jack
  • 6,848
  • 7
  • 37
  • 46
  • Why is this tagged 'kr-c'? The K&R2 book treats ANSI C, not K&R C. – schot Aug 25 '10 at 17:47
  • Similar question to: http://stackoverflow.com/questions/2892951/list-of-deprecated-c-functions There are good answers there. Look at the first comment of *KennyTM*. – karlphillip Aug 25 '10 at 17:17

3 Answers3

4

You can also look at the 'C' specifications that have come out since (like C99). These specs will indicate what they have added/removed/changed in relation to the previous standard.

http://en.wikipedia.org/wiki/C_%28programming_language%29

http://en.wikipedia.org/wiki/C99

http://en.wikipedia.org/wiki/C89_%28C_version%29

If you want to see what the future holds for 'C', have a look at C1X, which is the upcoming 'C' standard.

http://en.wikipedia.org/wiki/C1x

Edward Leno
  • 6,257
  • 3
  • 33
  • 49
1

If you can grab a copy of the ISO C99 standard, the Foreword includes a nice 2-page list of major changes since C90.

ninjalj
  • 42,493
  • 9
  • 106
  • 148
1

Not very much has changed. For most practical purposes, the language described in K&R2 is still the one to use. There has been a new C standard in 1999, but that has not been adopted as successfully and widely as the 1989 version of the standard (which K&R2 also describes).

The most important changes in C99 that could break existing programs are:

  • The implicit assumption of type int in declarations has been removed. Just make sure you always explicitly specify the types of your functions and variables.
  • Calling a function without a prior declaration is deprecated. Just make sure you declare all functions before use, preferably with a prototype.

Both of these were hold-overs from pre-standard days and have been considered bad-practice for a long time.

The one function to avoid is (and has always been) gets().

Bart van Ingen Schenau
  • 15,488
  • 4
  • 32
  • 41