if anyone could help me and tell me what's wrong or give me some hints...

I am trying to read in a file called "data" using a function called "readfile", but I keep getting "segmentation fault (core dumped)" when I run my program.

Here is my code (I have commented out some parts of it because I just want to get the reading in a file working first):

#include <stdio.h>
#include <string.h>
#define SIZE 100

int readfile(char *filename, char *names [], int numbers [] );
/*void nametoupper(char name [] );
void sortbyname(char *names [], int numbers [], int size );
void sortbynumber(char *names [], int numbers [], int size );
void swap(char *string1, char *string2);
void printall(char *names [], int numbers [], int size );
*/
int main ()
{
char *filename;
char *names [50];
int name;
int numbers [SIZE];

printf("Type the name of the file to be sorted:\n");
scanf("%s", filename);

readfile(filename, names, numbers);
/*nametoupper( names );
sortbyname( names, numbers, size );
printall( names, numbers, size );

printf("Press any key to continue:\n");
getchar ();
sortbynumber( names, numbers, size );
printall( names, numbers, size );
*/
return 0;
}

Here is the readfile function code:
#include <stdio.h>
#include <stdlib.h>

int parseline(const char *text, char **name, int *num);

int readfile(const char *filename, char *names[], int numbers[])
{

FILE *fp;
char textline[256];
char *status;
int countlines = 0;
int len;
int linestat;

/* Try to open the file, bail out if it can't be done */
fp = fopen(filename,"r");
if (fp == NULL) {
fprintf(stderr,"Unable to open file %s\n",filename);
exit(1);
}

status = fgets(textline, 255, fp);
while (status != NULL) {
len = strlen(textline);
if (textline[len-1] == '\n') {
textline[len-1] = '\0';
}
linestat = parseline(textline,&(names[countlines]),&(numbers[countlines]));
if (linestat != -1) {
countlines += 1;
}
status = fgets(textline, 255, fp);
}

return(countlines);
}

int parseline(const char *text, char **name, int *num) {

int last;
int index;

last = strlen(text) - 1;
index = last;
while ((isspace(text[index])) && (index >= 0)) {
index -= 1;
}
while ((isdigit(text[index])) && (index >= 0)) {
index -= 1;
}

if ((index > 0) && (index < last)) {
*num = atoi(&(text[index+1]));
*name = (char *) malloc((index+2)*sizeof(char));
strncpy(*name,text,index+1);
(*name)[index+1] = '\0';
return 0;
} else {
fprintf(stderr,"Warning: this line is not in the right format\n %s\n",text);
return -1;
}
}

And here is the "data" I want to input as the filename to be sorted:

Chad Lewis 15
Sean Lowe 23
Harold Dane 46
Sam Zane 34
Shiki Lars 89


If anyone could help me....

Thanks,
Newbie