Skip to main content

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
-3 votes
0 answers
66 views

Are pointer variables sometimes faster to initialize than reference variables?

Let's say just for acquiring the MEMORY-ADDRESS and VALUE of some variable. If the variable is "nested" in pointers like so: int val = 10; int *ptr1 = &val; int *ptr2 = ptr1; int *ptr3 =...
ZenPyro's user avatar
  • 95
2 votes
3 answers
45 views

Why does this Linked List C function not work properly if previousNode->next is not set to NULL?

Node* deleteAtTail(Node* head) { if (head == NULL) /* If List is empty... */ { return NULL; } else /* ...
BMAGS's user avatar
  • 29
2 votes
2 answers
64 views

Do brackets have effect during array of pointers declaration?

Recently I was reading "The C programming language" text book by Brain and Dennis and encountered that there is a difference between the pointer array definitions shown below: int (*a)[10]; ...
Abenaki's user avatar
  • 23
3 votes
0 answers
97 views

How do I pass a head-tail linked list to a function immutably?

If I need to pass a reference to an int immutably, I can pass it as a const int* to a function, as opposed to int*. This also helps the interface show that the pointed data won't be mutated. Now I ...
poss's user avatar
  • 31
0 votes
0 answers
14 views

Error while assigning a structure pointer member value

I got this error "error #28: expression must have a constant value" while trying to assign a pointer to structure member value to another as seen below typedef struct { int x; int y; }...
user26288104's user avatar
2 votes
2 answers
89 views

Circular linked list, destructor delete order causing seg-fault

Overview I have a simple circularly linked list I was making for demonstration purposes (I know I should be using smart pointers, but this is a pedagogical exercise for memory and data structures). ...
Amiel's user avatar
  • 21
2 votes
1 answer
21 views

Longest Repeating Substring With Replacement

Working on an online practice problem and ran into an issue that I can't seem to figure out. I am looking to find the longest length of a string of characters whose characters can only be replaced &...
EdAlex's user avatar
  • 45
0 votes
0 answers
34 views

Issue of readdir() reading the pointer to a directory

The basic logic in this problem is that the program scans over a directory for N times, and does some operation on specific file inside. The bug comes out as: program employs rewinddir() to put the ...
Yuming_J's user avatar
1 vote
2 answers
65 views

Typedef for 2 dimensional array in C and acess over pointer

I create custom type for table (2 dimensional array): typedef int table_t[4][2]; // 4 rows, 2 columns Next, I declare table and pointer to the table: table_t a = { {10, 0}, // my table ...
Vyacheslav Verkhovin's user avatar
-9 votes
0 answers
102 views

Can a pointer point to a pointer? [closed]

I have doubt here, str has address of the character. Now, result is a pointer which is declared, and the variable 'str' holds the value "address of the character" , and how can a pointer ...
Rohith Mani varma's user avatar
-3 votes
2 answers
48 views

Pass Function with Struct Parameter to a Struct in Go [duplicate]

Taking this example struct (my side): type Route struct { // other fields Handler func(any) } This is what the example user of my code would look like: type HelloWorldInput struct { ...
theheavycoder's user avatar
1 vote
0 answers
86 views

Problem with malloc and shared memory in C

I am trying to put shared_pid_data in shared memory. I need to have a dynamic array, so I use malloc, I also tried using calloc getting the same result. The problem I am encountering is that the data ...
MiusiZ's user avatar
  • 201
-1 votes
1 answer
68 views

clang++ and g++ Compiler gives different output when printing char pointer [duplicate]

clang++ and g++ Compiler gives different output when printing char pointer #include <iostream> int main(int argc, char** argv){ char a = 'a'; char* aptr = &a; std::cout << aptr &...
dtDhruv's user avatar
1 vote
1 answer
75 views

C pointers: Function returns a pointer defined in its body [duplicate]

I'm learning C using the book C Programming: A Modern Approach and I have some doubts about the use of pointers and referencing an out-of-scope variables. I've put together three examples to ...
videbar's user avatar
  • 33
-1 votes
1 answer
59 views

Dereferencing pointers in a slice does not seem to yield the initial value that the pointer was created from [duplicate]

I need to make a slice of pointers for a Go project I'm working on, that references the items in a slice. The expected behavior would be that I could modify one of the dereferenced items in the slice ...
kanennn's user avatar
  • 44

15 30 50 per page
1
2 3 4 5
3787