n strings allocation

Write a program to allocate memory for n number of strings dynamically. Input has to given at run time.

#include<stdio.h>
#include<stdlib.h>
int main()
{
	char **p,i;
	int n;
	printf("How many strings = ");
	scanf("%d",&n);
	p = (char**)malloc(sizeof(char*) * n);
	for(i = 0;i < n;i++)
		p[i] = (char*)malloc(50);
	printf("Enter %d strings\n",n);
	for(i = 0;i < n;i++)
		scanf(" %[^\n]",p[i]);
	printf("Strings are\n");
	for(i = 0;i < n;i++)
		printf("p[%d] = %s\n",i,p[i]);
	for(i = 0;i < n;i++)
		free(p[i]);
	free(p);
	p = NULL;
	return 0;
}

Output

How many strings = 3
Enter 3 strings
Lot
To
Learn
Strings are
p[0] = Lot
p[1] = To
p[2] = Learn