which declares a 2D array of pointers to char, should be:
which declare an array of (allocated) strings.
as names[x] is only the 1st character of the xth string. You should also make sure scanf does not overrun the allocated space.
same thing here, this should be names[x] only.
You were using unallocated memory.
There are no compilation errors, but the program crashes after the first name is entered