I am working with cortex-m4 microcontroller from TI TM4C123GH6PM. I am trying to allocate the memory space by following c syntax
char *target; int size=10; target=(char *)malloc(size*sizeof(char)); //allocating size for string if(target==0)red; else green; free(target);
The line where I am trying to assign the allocated space address to the char pointer cause Reset Handler to trigger at line LDR R0, =SystemInit
Disassembly 0x0000090c BEAB 0xAB
commenting that line cause to glow red led, means rest of the lines are executing perfectly. Same with the calloc function. I don't have any idea about this error please help.
Note that a compiler implementation where "char" has 16 bits, would still have sizeof(char) == 1.
So sizeof(char) isn't 1 because the char is one octet large, but because "char" is the unit type for memory sizes.
So sizeof(double) doesn't tell the number of octets, but how many "char units" that is needed to store a double.