Questions tagged [pointers]

0 votes
0 replies
how to change value of somthing in the array using pointer without using square brackets [closed]
it gives me the error of not being able to use the code because of the pointer :) #include <stdio.h> #define LENGTH 31 void get_boom_numb...
asked 1 month ago
0 votes
1 replies
I am confused how to understand this code. contains double pointers
I don't understand why the code below changes the array b: int a[] = { 3, 6, 9 }; int b[] = { 2, 4, 6, 8, 10 }; int **c; int **d[2]; c = (int **...
asked 1 month ago
1 votes
1 replies
Trying to recreate the strcpy function using pointers
I am trying to learn pointer by recreating the strcpy function in C. It stopped working whenever I have space, tab in my input string (anything o...
asked 1 month ago
-1 votes
1 replies
How can I access a memory buffer mapped into a swift structure?
This is probably trivial for you, but I am new in Swift and I can't find the answer. I use C code to convert data from TCP/IP, that all works fi...
1 votes
1 replies
Problem creating and returning jagged array (error std::bad_array_new_length)
For this homework problem, we need to create a new jagged array with the code provided by our professor, print the array, and calculate the max,...
asked 1 month ago
1 votes
1 replies
Printing a hashtable in the order elements were inserted
So i have this hashtable that's working fine but i need a way to print it's elements in the order they were inserted. I've been thinking about ho...
asked 1 month ago
1 votes
1 replies
How to fill an array of structs using a pointer while reading from a file in C
the following has poped up while studying and I would like whether it does what it is supposed to. Let's say we have the following struct: typed...
asked 1 month ago
1 votes
2 replies
Modifying a pointer in a function [duplicate]
This question already has an answer here: How do I modify a pointer that has been passed into a function in C?...
0 votes
1 replies
Correct way of calling a c function that expects const char8 string[] as parameter
Inside an ISR of a microcontroller I am attempting to call a function as follows: //adc.c static volatile char uartBuf[6]={0}; CY_ISR(ISR_ADC)...
asked 1 month ago
-1 votes
1 replies
Struct passed from pointer shows wrong values
I have a variable struct employee which I initialized on the heap using malloc. I am passing this variable from a pointer using *tmp as shown bel...
asked 1 month ago
-3 votes
1 replies
Can someone tell me why I am unable to find the length of array using sizeof() function here?
When I changed the code to include an argument for size, the code worked correctly. But I cannot understand the error it is showing when I'm calc...
asked 1 month ago
-2 votes
1 replies
printf treats *p++ differently from what happens to p [duplicate]
This question already has an answer here: Pointer expressions: *ptr++, *++ptr and ++*ptr...
asked 1 month ago
0 votes
2 replies
How to store a unsigned char array to float value?
I am trying to take the sensor data from Arduino & Raspberry Pi using RS232 serial communication. I have searched for this small thing and fo...
asked 1 month ago
0 votes
0 replies
Referenced array object doesn't return class variable when iterating - terminate called after throwing an instance of 'std::logic_error'
So I'm trying to iterate through a dynamic array(required) of a class "Candidate" which has the getter "getVotes()" in order to get the votes to...
asked 1 month ago
0 votes
2 replies
Dummy value output by Pointer
I am passing the structure pointer to function and accessing it in function but the pointer points to dummy value after the it enters this functi...
asked 1 month ago
0 votes
0 replies
How to fix problems with vector and T*
I'm having a task, where I have to make a C++ implementation of a Java style ArrayList. But in a couple of areas I'm having some trouble. The de...
4 votes
3 replies
Freeing memory with delete vs smart pointer and proper way of freeing memory
I'm doing a project for the university and im trying to find out how to delete memory properly and if the way of deleting that i came up with wil...
asked 1 month ago
0 votes
1 replies
Dynamic Memory Allocation and Heap Corruption
For an assignment for school, I need to create a program that takes one array and splices another into it, assigning the first X values of the fi...
0 votes
2 replies
allocating memory for structure pointers
Why is it that when we declare a structure pointer we need to allocate memory struct A{ /// }; int main(void) { struct A *var=(struct A*)ma...
asked 1 month ago
0 votes
1 replies
How to use abstract class' children instances through methods?
I have an abstract class Player and its children AI and Human. In my main, when I create two objects Human and AI it works fine. But once I use t...
asked 1 month ago
0 votes
0 replies
Saving struct members in a linked list and saving them
I just recently started learning pointers and linked lists in C and there are some things i don't understand yet. I'm trying to cut an input stri...
asked 1 month ago
-1 votes
1 replies
Unexpected segfault when creating a binary tree
I've got the following representation for a BinaryTree class: #include "treecode.hh" Treecode::Treecode(){} Treecode::Treecode(string s, int f)...
asked 1 month ago
2 votes
2 replies
Setting a variable equal to a variable that is equal to nullptr
I have an array called my_array of linked lists. Node* x = my_array[0]; if (head == nullptr) { my_array[0] = new Node; } How come this one...
asked 1 month ago
-1 votes
0 replies
Raycasting with triangles - Access an array in an array
I'm calling the function const triangle_t* findClosestHit( const float3& p, const float3& d, const triangle_t* triangles, std::size_t nu...
asked 1 month ago
-2 votes
0 replies
Create a new edge in a Graph Class
This is my first time in StackOverflow... I'm trying to make working a Graph Class on c++. The compiler shows me the following msj in the "insert...
asked 1 month ago