I am trying to allocate memory for three string and print it to screen.but it isnt working .can anyone explain what's wrong here
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main()
{
char **name;
int i;
name=(char **)malloc(3 * sizeof(char *));
while(i<3){
name[i]=(char *)malloc(20 * sizeof(char));
}
while(i<3){
scanf("%s",name[i]);
}
while(i<3){
printf("%s",name[i]);
}
getch();
}