Use following snippet of code to get each character one by one
for(int i=0; i<noOfLine; i++){
for(int j=0; a[i][j]!='\0'; j++)
printf("%c", a[i][j]);
}
instead of
for(index = 0; index < noOfLine; index++)
printf("%s", a[index]);
From my snippet you can understand that pointer of array are no differ than 2-d array when allocating a fix amount of memory whether at compile time or at run time.
You could have used malloc function after getting number of string and finding length of each string. So that memory can be allocate accordingly to save memory at runtime.
In your case we have to allocate 500*500 memory blocks, which doesn't look good. If you are using malloc function, then use it to assign optimal amount of memory.
If you found an error, feel free to point out.