### Thread: Pointer to a vector of vectors

1. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
May 2013
Posts
57
Rep Power
0

#### Pointer to a vector of vectors

Do you know how to do it? I have an error:

If radius . front is a function, it isn't really. It could be a pointer to a function. Therefore, you ought to write

Since c will recognize what you mean, (*(radius.front))() probably returns a number. You want to take the address of a number?

3. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
May 2013
Posts
57
Rep Power
0
I m sorry I did not explain well. Googling it I see someone using this kind of code. I just need to know how assign a pointer to a vector of vector. Because I have en error.
4. If you wanted this in C++ you'll have to get someone else to explain the templates.
Code:
```/*
* compilation and example
*
* \$ a=./c && make -k \$a && \$a
* cc -Wall c.c -lm  -o c
* 2.71828 - 2.718 is 0.000281828
*/

#include<math.h>
#include<stdio.h>

/* f returns a pointer to a pointer */
double**f(void) {
static double x,*px;
x = 2.718;
px = &x;
return &px;
}

int main() {
double**ppx = f();
printf("%g - %g is %g\n", exp(1), **ppx, exp(1) - **ppx);
return 0;
}```
5. No Profile Picture
Contributing User
Devshed Newbie (0 - 499 posts)

Join Date
May 2013
Posts
57
Rep Power
0

#### Glibc error

Hi people I have this error entering a function:
(really the error lines are more than this I put)

Code:
```*** glibc detected *** /home/elvio/workspace/aws/Debug/aws: double free or corruption (!prev): 0x0000000001eff100 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x7eb96)[0x7f950c739b96]
/home/elvio/workspace/aws/Debug/aws[0x40afde]
/home/elvio/workspace/aws/Debug/aws[0x40a940]
/home/elvio/workspace/aws/Debug/aws[0x409f3b]
/home/elvio/workspace/aws/Debug/aws(_ZNSt6vectorId```
The function is : (I print Welcome to see in console I enter in the function)

Code:
```void pre_filter_Computations(vector< vector<double> > radius,vector< vector<double> > theta,int cols,int rows){

vector<double>x(cols);
vector<double>y(rows);
vector< vector<double> >X(cols, vector<double>(rows));
vector< vector<double> >Y(cols, vector<double>(rows));
double epsilon = 0.0001;

printf("welcome\n");

for(int i=0;i<cols;i++){
x[i]=((double)(i-cols)/2)/((double)cols/2);
}

for(int z=0;z<rows;z++){
y[z]=-(((double)(z-rows)/2)/((double)rows/2));
}

for(int m=0;m<cols;m++){
for(int n=0;n<rows;n++){

X[m][n]=x[m];
Y[m][n]=y[n];
}
}

for(int a=0;a<rows;a++){
for(int b=0;b<cols;b++){

X[a][b] = pow(X[a][b],2);
Y[a][b] = pow(Y[a][b],2);
X[a][b] = X[a][b] + Y[a][b];

}
}