Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [pointers]

Data types for "pointing" at other values: A pointer's value is a memory address where the pointed-to value is stored. This tag should be used for questions involving the use of pointers, not references. Common programming languages using pointers are C, C++, Go, and assembly and intermediate-representation languages; use a specific language tag. Other helpful tags should describe what is being pointed-to (e.g. a function, a struct etc.)

pointers
2 votes
1 answer
113 views

array of pointers to pointers to integers VS pointer to pointer to array of integers

I have 3 integers A, B & C from which I make pointers that I group in an array arrayABC of pointers to pointers: int A = 1; int B = 2; int C = 3; int *ptA = &A; int *ptB = &B; int *ptC = &...
Steens's user avatar
  • 128
1 vote
1 answer
28 views

Can't put values together into struct that is initiated by pointer and malloc [duplicate]

Just a simple struct called person, inside I need to store name and age. I'm trying to dynamically allocate memory for my struct. Without using pointer: #include <stdio.h> #include <stdlib.h&...
cutelittlebunny's user avatar
-11 votes
0 answers
63 views

What's the difference between 'ClassName* p' and 'ClassName p'? [duplicate]

Please explain to me the difference between Player p and Player* p. Why should I write it like this: Player *p = new Player(playwin, 1, 1, '#'); while (p->getmv() != 'x') { p->display(); ...
Иванов Леонид's user avatar
0 votes
1 answer
17 views

Struct and Pointers: Please help me understand this line of code

Please help me understand what does the last line does: int PCKT_LEN = 8192; char buffer[PCKT_LEN]; struct iphdr *ip = (struct iphdr *) buffer; struct udphdr *udp = (struct udphdr *) (buffer + ...
X-Maki's user avatar
  • 41
-3 votes
0 answers
122 views

Are pointers smartly allocated? [duplicate]

While learning about pointers in Uni, They taught us that pointers are allocated memory for the address to be stored. And while I was messing around with pointers and null pointers. I noticed this ...
Vishvanathan K's user avatar
1 vote
0 answers
39 views

Passing an array to a function in C - array subscript vs pointer dereferencing [duplicate]

Coming from mainly Python and JavaScript I (think I) understand that when you pass the name of an array to a function, the array is decayed to a pointer. The part that confuses me is the fact that the ...
bytecafe's user avatar
-2 votes
0 answers
95 views

Pointer "ptr + offset" vs "&ptr[offset]" [closed]

Consider a piece of code in C as shown below int arr[1000]; int offset = 500; int *ptr_array = (int *)&arr[0]; int *ptr_temp1 = ptr_array + offset; // ---> method-1 int *ptr_temp2 = &...
SakSath's user avatar
  • 145
1 vote
1 answer
128 views

Specify the type of a C++ pointer at runtime (generic pointer)

I am developing a simulation code written entirely in C++ where we use double precision for all computations. Now I want to make it configurable to use single precision if the user wants. The problem ...
Dan's user avatar
  • 144
1 vote
0 answers
19 views

redefine pointer to function (to a function, not an object or to a variable) inside another function [duplicate]

How can I redefine a pointer to a function inside another function? In JS variables are passed by value and objects are passed by reference (these are pointers in some way). I thought functions were ...
J. Pablo García's user avatar
2 votes
3 answers
123 views

Converting to char*** from char* [2][2]

I have the following variable char* a[2][2] = {{"123", "456"}, {"234", "567"}}; I wanted to refer it using another variable. While the cast works, accessing ...
Sreepathy's user avatar
0 votes
1 answer
114 views

Why does defining the elements of the array b is required to get the desired output

I recently learnt about typecasting pointers. So I played around, and made this bad code: #include <stdio.h> int main() { int* a; char b[]= "Hye"; a = (int*)&b; *a='...
Rajesh Paul's user avatar
2 votes
1 answer
107 views

Is comparing two pointers to different char objects undefined in C?

This is code of memmove from https://github.com/gcc-mirror/gcc/blob/master/libgcc/memmove.c void * memmove (void *dest, const void *src, size_t len) { char *d = dest; const char *s = src; if (d &...
k1r1t0's user avatar
  • 735
-6 votes
2 answers
71 views

malloc(): corrupted top size on deleting an entry from binary file [closed]

I AM CREATING A SCHOOL MANAGEMENT SYSTEM . WHEN I TRY TO DELETE A STUDENT AFTER ADDING ONE I AM GETTING "malloc(): corrupted top size" ERROR .CANT FIND THE REASON.I AM A BEGINNER , HELP ...
ASHNA A's user avatar
1 vote
3 answers
101 views

In C, why can a variable holding a char array be assigned to a pointer, but the address of the same pointer cannot?

Consider the following code: char stringy[] = "There's too much confusion, I can't get no relief!"; char *pStringy; pStringy = stringy; This compiles - stringy is an array of characters, ...
Bennypr0fane's user avatar
0 votes
0 answers
38 views

A property of Python class returns an empty numpy array with pybind11

I adopted a project that was abandoned by it's original creator on GH: pybind11 bindings for whispercpp. I had to update Python version from 3.8 to 3.11.8 in CI and discovered that some of the test ...
WintermuteAI's user avatar

15 30 50 per page
1
2 3 4 5
3788