Skip to main content
0 votes
0 answers
56 views

I mean that i is incremented by 1 right, then how does ptr + i equals ith block of memory since int size is 4? int i, n; printf("Enter the number of Integers: "); scanf("%d&...
0x0pralad0x0's user avatar
5 votes
5 answers
252 views

There are several source code files of a program. File file_a.c has an array in the global scope, and a function is provided that returns a pointer to its beginning: static int buffer[10]; int *...
Evgeny Ilyin's user avatar
-1 votes
2 answers
152 views

As far as I understand, pointer arithmetic is defined mainly in expr.add. But it seems defined only for static arrays, not dynamic ones: 4 When an expression J that has integral type is added to or ...
Oersted's user avatar
  • 3,732
1 vote
1 answer
183 views

Most low-level allocation functions return void *. If I want to perform pointer arithmetic on the obtained memory and/or allocate an array, is this the correct way to do it without invoking undefined ...
Oersted's user avatar
  • 3,732
1 vote
0 answers
90 views

I ran to an over-specialized container somewhere in production code. It was C++98 upgraded to C++11, but I wonder how many UBs (or implementation-defined behaviors) are in it. Basically, without any ...
Swift - Friday Pie's user avatar
2 votes
4 answers
302 views

I am currently learning about pointers in C programming as part of my training. I am particularly curious about using pointers directly within "for" loops. For example, in the following &...
Mehdi's user avatar
  • 21
3 votes
1 answer
173 views

Pointer arithmetic is only defined behavior for pointers to elements of the same array (or one past the array). Is there any defined behavior to get the distance in memory between two elements that ...
greenlagoon's user avatar
2 votes
1 answer
143 views

This is in one sense an extension to Is it UB to access a subobject by adding byte offset to the address of the enclosing object? under the assumption that P1839 is adopted. Consider the following ...
LtSten's user avatar
  • 175

15 30 50 per page
1
2 3 4 5
51