things about realese memory for characters array and array of char array
:devil:im stuck in the memory problem
1,
Code:
char string[10];
while (fgets(string, 10, stdin) != NULL)
{
//printf string
// printf string[7]
}
then, string will equal to every line from user stdin,
suppose:
i tried to stdin two times, first time, i input "hello ha\n" first, then print string => "hello ha"
then, if i input "hello\n", the print out string is "hello", this is fine, but if i print string[7], the output is 'o'.. is this because the original memory didn't released, so the index 7 still have the previous value?
but if this is why, then why the output if print string is "hello"?
2, talking about memory, is there any formal way to release previous array memory, for example, if im dealing with char matix[0][0] an array of characters array, how to clean all the value i assigned to matix before, then i can assign new value to it again
~~~~!!!!!!~!~!~!~!~!~!~! looking forward some replys