All Questions
Tagged with pointer-to-pointer multidimensional-array
10 questions
0
votes
3
answers
123
views
Accessing information on a 2d array with a double pointer in a struct (C)
In trying to understand pointers, I created a M[x][y] array, a pointer to said array *p_M[x] and a pointer to said pointer **d_p_M. The first pointer points to the first element of a row in the array ...
0
votes
1
answer
2k
views
Getting "corrupted size vs. prev_size" in C++
I'm trying to create a program to print a 2D matrix after reading in data from a file.
My program works fine if the 2D matrix is a square with equal X & Y values, but I get the "corrupted ...
0
votes
1
answer
180
views
dynamic array of strings, but i get heap corruption detected
I try to make a dynamic array of char pointer, what means does pointers can be a dynamic memory too, so in the code above I try to allocate one size to the array and in him, allocate to the first ...
3
votes
4
answers
474
views
Assign a pointer by a pointer to multidimensional array in function [duplicate]
void print_first_n_row(double **matrix, int n, int row_size) {
double (*abc)[row_size];
abc=matrix;}
I am having assignment from incompatible pointer type [-Wincompatible-pointer-types]
abc=matrix ...
1
vote
2
answers
73
views
pass address of arr[0][2] , that must be received in a double pointer
need a better approach to pass address arr[0][2], given that is has to be received in a double pointer.
want to pass arr[0][2] without storing in any other variable.
#include <iostream>
using ...
1
vote
0
answers
839
views
Passing 2D Integer Array as double-pointer to a function VS 2D String Array as double-pointer doesn't behave the same? [duplicate]
Hi I am trying to understand the difference between passing a 2d array of type char VS type int to a function as a double-pointer func(int **ptr) parameter. The problem is that it behaves differently. ...
0
votes
1
answer
70
views
C, Dynamic allocation of a matrix: Why is this not allowed?
So I have the following example in some lecture notes
void f(int **p){}
void g(int *p[]){}
void h(int p[2][3]){}
int main(){
int **a;
allocate_mem(a); // allocate memory for a
f(a); // OK!
...
0
votes
2
answers
229
views
How to input different values into a 2D pointer-to-pointer array using a for loop C++
I have created two arrays, friends and timechat. Instead of writing long code that manually puts each piece of data into the 2d array I want to do it with a for loop. I have created a 2D array, 2 ...
2
votes
2
answers
1k
views
Difference between pointer to pointer and pointer to 2d array
If I have a 2d array B defined as :
int B[2][3] = {{1,3,5},{2,4,6}};
Is int **p = B same as int (*p)[3] = B ?
int **f = B; printf("%d ",*f+1);
gives 5 as output while printf("%d ",*f) gives 1 as ...
2
votes
5
answers
1k
views
Pass multiple-dimensional array to a function in C
I have a function like this:
void myfunc(int** arr, int n) {
int i, j;
for(i=0; i<n; ++i) {
for(j=0; j<n; ++j) {
printf("%d,", *(arr + i*n + j) ); // Print numbers with commas
...