I have a simple problem with pointers. Here is my code:
#include <iostream>
#include <vector>
using namespace std;
int main()
{
typedef float RtPoint[3];
RtPoint** b = new RtPoint*[4];
b[0] = (RtPoint*)new RtPoint;
RtPoint* p = b[0];
RtPoint c;
(*p)[0] = &(c[0]);
(*p)[1] = &(c[1]);
(*p)[2] = &(c[2]);
std::cout << p[1] << " " << &(c[0]) << std::endl;
delete[] b;
return 0;
}
So I just want put in p[0]
, p[1]
and p[2]
the address of c[0]
, c[1]
and c[2]
. My code is wrong but I didn't find a solution.
Sorry my fault this code works :)
typedef float RtPoint[3];
RtPoint** b = new RtPoint*[4];
b[0] = (RtPoint*)new RtPoint;
RtPoint c;
b[0] = &c;
Edit: yes I've seen my error