Unfortunately, your code will trash the heap. You only malloc'ed one char. Scanf will return anything entered BUT the newline. Malloc for a single char is hideously inefficient, and the overhead for managing that memory will be many times as large as the single char. Additionally, you have an error here:
Code:
scanf("%[^\n]",char);
char is a type, not your pointer.