I am currently trying to develop a neural network program for pattern recognition. The basis for the neuron are sigmoid neurons, and the network has three layers. At the moment I am trying to develop the first layer, which is an input layer. The code I have at the moment takes it a array of characters I have defined and tries to allocate one character per node. TO MAKE THAT CLEAR, the function I am trying to write takes in one value from the array i.e. the character at array[0] and assign it to a new nodes' input value.
Now there are 64 values in my array[], and there fore I want 64 nodes, with each node only containing one of the values from the array.
TLDR
My issue is, when i try to assign a single value from my array to a new node the struct array will not copy the value. therefore when I print this value the out is (NULL). Why is this happening? By the way I am fairly new to dynamic memory allocation.
Any help is much appreciated!!
Thank you!
Here is the function where it takes an input char array and assigns each character to a new node.
input *input_array = malloc(sizeof(input)*SIZE);
int counter = 0;
char input_char;
while (counter < (SIZE)){
input_char = array[counter];
input_array[counter].input_value='a';
counter++;
printf("%c, %c at %d\n",array[counter], input_array[counter].input_value, counter);
}
return input_array;
The struct looks like this
typedef struct input_node {
char input_value;
} input;