If I have an array of pointers as you defined above:
ie. float *float_ptr[4]
and I wanted to do the following:
store the data set [0 1 2 3 4 5] into float_ptr[0]
and store [0 1 3 4 8 10] into float_ptr[1]
similarly for the next two, how would I go about doing that?
I have an idea as listed below, however the syntax doesn't yield the results I want, obviously which is why I am writing you.
int j, i;
int array1[24] = {0, 1, 2, 3, 4, 5 , 0, 1, 3, 4, 8, 10, 1, 9, 3, 4, 6, 21, 0, 1, 1, 9, 6, 12};
float *float_ptr[4], a, b, c, d;
for (j = 0; j < 4; j++)
{
for (i = 0; i < n; i++)
{
if (i == 0)
{
a = (float)array1[i * 4 + j] - 1.88;
float_ptr[chan_int][i * 4 + j] = a;
}
else if (i == 1)
{
b = (float)array1[i * 4 + j] - 1.88;
float_ptr[chan_int][i * 4 + j] = b;
}
else if (i == 2)
{
c = (float)array1[i] - 1.88;
float_ptr[chan_int][i * 4 + j] = c;
}
else if (i == 3)
{
d = (float)array1[i] - 1.88;
float_ptr[chan_int][i * 4 + j] = d;
}
}
}
As you can see there is a double index for float_ptr, which is the issue, and I am not sure what to replace this with. Thanks!!
-Ben
arraysri November 16, 2011 at 6:24 PM
very clear notes
hikumar February 8, 2012 at 12:52 AM
plz send clear explanation of following program: main() { char c[]="gate2011"; char *p=c; printf("%s",p+p[3]-p[1]); }
c++sanjeev kumar May 19, 2012 at 7:33 AM
its very good subject
thanksshan June 15, 2012 at 5:21 PM
thanks for post this topic its very useful :D
Array of PointersBen November 17, 2012 at 12:51 AM
If I have an array of pointers as you defined above: ie. float *float_ptr[4] and I wanted to do the following: store the data set [0 1 2 3 4 5] into float_ptr[0] and store [0 1 3 4 8 10] into float_ptr[1] similarly for the next two, how would I go about doing that? I have an idea as listed below, however the syntax doesn't yield the results I want, obviously which is why I am writing you. int j, i; int array1[24] = {0, 1, 2, 3, 4, 5 , 0, 1, 3, 4, 8, 10, 1, 9, 3, 4, 6, 21, 0, 1, 1, 9, 6, 12}; float *float_ptr[4], a, b, c, d; for (j = 0; j < 4; j++) { for (i = 0; i < n; i++) { if (i == 0) { a = (float)array1[i * 4 + j] - 1.88; float_ptr[chan_int][i * 4 + j] = a; } else if (i == 1) { b = (float)array1[i * 4 + j] - 1.88; float_ptr[chan_int][i * 4 + j] = b; } else if (i == 2) { c = (float)array1[i] - 1.88; float_ptr[chan_int][i * 4 + j] = c; } else if (i == 3) { d = (float)array1[i] - 1.88; float_ptr[chan_int][i * 4 + j] = d; } } } As you can see there is a double index for float_ptr, which is the issue, and I am not sure what to replace this with. Thanks!! -Ben
c,c++suhasini February 21, 2013 at 6:44 AM
is there any need to learn these language? ........kindly plz tell me
Post your Comment