I thought I was finally getting somewhere in C, but have hit a brick wall on this one. I've just spent the last 30 mins looking up possible solutions, some involving memcpy and strcpy etc, but none seem to fix my issue. It may be a case of me not using them correctly.
I've created a basic program illustrating my problem. I'm hoping be shown how to fix this part of the code will help me better understand where I'm going wrong.
#include <stdio.h>
#include <stdlib.h>
//The program is trying to attempt to give 'test[0] a value of 255'
int main(int argc, char ** argv)
{
//example variables
int height = 4;
int width = 4;
unsigned char image[width][height];
char *test;
//gave the 0th element a basic value
image[0][0] = 255;
//prints out 'Image = 255' as expected
printf("Image = %d\n", image[0][0]);
//allocate test some memory
test = malloc(height * width * sizeof(char));
//Now the problems..
//attempt to give test[0] the value of image[0][0]
test[0] = image[0][0];
//prints out '-1'
printf("Test = %d\n", test[0]);
}