unsigned char *array[SOME_VALUE];
now I want to access each byte in each element of that pointer array.
is this correct??
unsigned char temp = array[0][/*bytes are found here*/];
Thanks
unsigned char *array[SOME_VALUE];
now I want to access each byte in each element of that pointer array.
is this correct??
unsigned char temp = array[0][/*bytes are found here*/];
Thanks
#include <string.h>void main() { unsigned char *array[255]; unsigned char temp[255]; strcpy(temp, "blah"); // write "blah" to temp array[0] = new char[strlen(temp)+1]; // define array[0] strcpy(array[0], temp); // write temp to array[0] // Do whatever you want with array[] delete [] array[0]; // delete array once your finished}
quote:Original post by drekkar
unsigned char tmp = *array[/*element number*/];
*array[0]//now that I have element 0 I want to access its bytes
int **ip = new int*[10];for(int x = 0; x < 10; x++)ip[x] = new int[10];for(x = 0; x < 10; x++)delete []ip[x];delete []ip;
int *p = new int(10);cout << p << "equals address";cout << *p << "equals value";//how do I go about this with multidim arrays that are allocated dynamically?
for(int i=0; i<nb_array; ++i){ unsigned char *one_array = array[i]; for(int j=0; j<size_of_array[i]; ++j){ cout << one_array[j]; }}
//your wayfor(int a = 0; a < imageSize; a +=colorMode){ colorSwap = *(imageData[index] + a); *(imageData[index] + a) = *(imageData[index] + (a + 2)); *(imageData[index] + (a + 2)) = colorSwap;}//my wayfor(int a = 0; a < imageSize; a +=colorMode){colorSwap = imageData[index][a];imageData[index][a] = imageData[index][a + 2];imageData[index][a + 2] = colorSwap;}