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
}
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 way
for(int a = 0; a < imageSize; a +=colorMode)
{
colorSwap = *(imageData[index] + a);
*(imageData[index] + a) = *(imageData[index] + (a + 2));
*(imageData[index] + (a + 2)) = colorSwap;
}
//my way
for(int a = 0; a < imageSize; a +=colorMode)
{
colorSwap = imageData[index][a];
imageData[index][a] = imageData[index][a + 2];
imageData[index][a + 2] = colorSwap;
}
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more