I am having trouble implementing dynamic memory allocation in to my program. I am trying to dynamically allocate memory for the products in my program. For some reason it will not compile. I keep getting these errors but can't find a way around it:
(65): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data
(67): error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
(119): note: see declaration of 'strcpy'
Any help will be greatly appreciated. Thank you in advance for any help.
(65): warning C4267: 'initializing': conversion from 'size_t' to 'int', possible loss of data (67): error C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
(119): note: see declaration of 'strcpy'
I did read the error and tried using strcpy_s and then it gave me another error: no instance of overloaded function "strcpy_s" matches the argument list. I did however figure it out I needed to add a second parameter for the size which I didn't know before hand. Thank you guys for the help.
I am doing an assignment for school and the assignment says "For the products, use an array of pointers to strings, and dynamically allocate space for each of the strings. To fill in the products array, read one product name from the user, check the length, and then allocate memory based on the length of the entered word."