Take Spaces as Input with scanf()

In a normal C program, giving an input in a field where scanf() is used, the part after the space disappears. It is basically because spaces, like the return command, are used to differentiate between two different inputs.
However, there is a way to take spaces as input as well.

#include <stdio.h>

int main()
    char str[50];
    printf("Enter any string:\n");
    printf("Entered string is: %s\n",str);

The "%[^\n]" basically tells the compiler that, take everything entered by the user as literal input except for the enter command which is represented by \n.