Skip to content

Tarik Billa

  • Web Development
    • html
    • vue.js
    • laravel
    • css
    • javascript
    • jquery
    • node.js
    • php
    • asp.net
  • Programming
    • python
    • java
    • c
    • c++
    • c#
  • git
  • android

pointer-arithmetic

How does this piece of code determine array size without using sizeof( )?

December 9, 2022 by Tarik

When you add 1 to a pointer, the result is the location of the next object in a sequence of objects of the pointed-to type (i.e., an array). If p points to an int object, then p + 1 will point to the next int in a sequence. If p points to a 5-element array … Read more

Categories c Tags arrays, c++, language-lawyer, pointer-arithmetic, size Leave a comment

Pointer arithmetic for void pointer in C

October 11, 2022 by Tarik

Final conclusion: arithmetic on a void* is illegal in both C and C++. GCC allows it as an extension, see Arithmetic on void– and Function-Pointers (note that this section is part of the “C Extensions” chapter of the manual). Clang and ICC likely allow void* arithmetic for the purposes of compatibility with GCC. Other compilers … Read more

Categories c Tags c++, pointer-arithmetic, void-pointers Leave a comment

With arrays, why is it the case that a[5] == 5[a]?

August 27, 2022 by Tarik

The C standard defines the [] operator as follows: a[b] == *(a + b) Therefore a[5] will evaluate to: *(a + 5) and 5[a] will evaluate to: *(5 + a) a is a pointer to the first element of the array. a[5] is the value that’s 5 elements further from a, which is the same … Read more

Categories c Tags arrays, c++, pointer-arithmetic, pointers Leave a comment
Newer posts
← Previous Page1 Page2

Tarik Billa

Software Engineer
tarikbilla@gmail.com
+8801884414000
  • Reuse a hash in YAMLApril 17, 2024
  • Dockerfile: how to redirect the output of a RUN command to a variable?April 16, 2024
  • How to cd to a directory with spaces in the directory name?April 16, 2024
  • Maximum MIME type length when storing the type in a databaseApril 16, 2024
  • What is the difference between Unit, Integration, Regression and Acceptance Testing?April 16, 2024
© 2026 Tarik Billa