Sunday, 18 August 2013

What are the differences in using malloc or not using it in this code?

What are the differences in using malloc or not using it in this code?

What is the difference if you were to do this:
char* memory = malloc(sizeof("String"));
memory = "String";
printf("%s", memory);
free(memory); //edit
Or this:
char* noMemory = "String";
printf("%s", noMemory);

No comments:

Post a Comment