Thrust vector of structs

Hello everyone,
I created a thrust device vector of a structs and i am not able to print it.Please help.

The struct goes:

struct point
{
int x;
int y;
};

And the device vector implementation goes:

thrust::host_vector<point> C3(10);
thrust::device_vector<point> D3 = C3;
point *d_c3=thrust::raw_pointer_cast(D3.data());

//Trying to print below
for(int i=0;i<D3.size();i++)
		cout<<"\n"<<D3[i].x;             //Line with error
	cout<<endl;

The error shown is :
class “thrust::device_reference” has no member “x”

static_cast<point>(D3[i]).x;

Thank You Very Very Much Respected episteme.
That worked wonderfully.

I’m not sure what your use-case is but consider that in CUDA, structures of arrays are preferable to arrays of structures.

By this I mean, instead of one array of structures, you have to arrays that you can use to represent the structure. Basically, take the x and y and make them their own array.

Fortunately, two ints are relatively small and CUDA has built-in vectorized types that you can use to load them in efficiently but in general, I think it’s advisable in CUDA to separate things into their own arrays.