char message[500];
printf("\nEnter your message (Not more than 500 words)\n->");
scanf("%s", message);
FILE *ptr;
ptr = fopen("file.txt", "w");
fprintf(ptr, message);
fclose(ptr);
Here I created an array called message and after receiving the input from the user, I printed the stored string into the file named 'file.txt' but it turns out that only first word of the message array is printing in the file. For example: If I typed 'Hello there, I am learning C' inside the message array and print it to the file, then only 'hello' is being printed on the file. Please explain elaborately.