It will warn you that you never assigned anything to ptr, ptr is uninitialized and points to a random memory location (warning will depend on the warning level).
It's also a good idea to initialize pointers to NULL,
ptr is only a pointer, it points to a memory location, memory which you possibly don't own.
Either, allocate memory on the stack or the heap.
stack:
Code:
char myArray[10];
fgets(myArray, sizeof(myArray), stdin);
or, the heap:
Code:
char * ptr;
if((ptr = malloc(10 * sizeof(char))) != NULL)
{
fgets(ptr, 10, stdin);
free(ptr);
}else{
/* failed to allocate memory */
}