Essentially, I'm trying to create a program that simply takes in input from the user and then prints it, using dynamically allocated memory. Yes I know how to do this the simple way, but I'm attempting to get to grips with the intricacies of memory management in C. So what is wrong with this code? it runs without error but when I enter in a string into the command line it stops working and throws an exception at a hexadecimal address. Thank you in advance.
int main() {
char *input;
input = (char *)malloc(20 * sizeof(char));
puts("Enter the string you wish to display");
scanf_s("%s", input);
printf_s("%s", *input);
free(input);
return 0;
}
#includes and tell us what platform you use.