What are convincing examples where pointer arithmetic is preferable to array subscripting?

前端 未结 9 575
没有蜡笔的小新
没有蜡笔的小新 2020-12-30 09:23

I\'m preparing some slides for an introductory C class, and I\'m trying to present good examples (and motivation) for using pointer arithmetic over array subscripting.

9条回答
  •  一整个雨季
    2020-12-30 10:29

    If you were using an old compiler, or some kind of specialist embedded systems compiler, there might be slight performance differences, but most modern compilers would probably optimize these (tiny) differences out.

    The following article might be something you could draw on - depends on the level of your students:

    http://geeks.netindonesia.net/blogs/risman/archive/2007/06/25/Pointer-Arithmetic-and-Array-Indexing.aspx

提交回复
热议问题