When I compile the following code, I get this exception:
Unhandled exception at 0x0FA8E90F (ucrtbased.dll) in console.exe: 0xC0000005: Access violation writing location 0xFFFFFFCD
void test()
{
char *type = malloc(sizeof(char) * 256);
strcpy_s(*type, 7,"Laptop");
}
I have to mention that I am a begginer in working with dynamic implementation and pointers. I am also not allowed to use a static implementation.
In the above snippet I also tried different implementations as: replacing the following line:
strcpy_s(*type, 7,"Laptop");
with this line:
strcpy(*type, "Laptop");
but the result was the same. Any suggestion for my problem?
Thank you in advance.