As already answered here, the problem is that you have not allocated any memory space to file1char.
You can also take a dynamic approach without too much complication, being able to carry out the process in files of any size, since you get character by character:
char Xseqpath[90];
sprintf(Xseqpath, "%s/xseqpath", mainfile);
FILE *File1 = fopen("ref.fasta", "r");
char* file1char = calloc(1,sizeof(char)); //calloc é mais seguro que malloc
int charnumber = 0;
while(fscanf(File1, "%c", &file1char[charnumber]) != EOF)
{
//"charnumber++" retorna o valor anterior de charnumber, e incrementa após retornar.
printf("%c", file1char[charnumber++]);
//Aumenta o tamanho de file1char dinâmicamente
file1char = realloc(file1char,(charnumber+1)*sizeof(char));
}
fclose(File1);
free(file1char);
return 0;
But if you don’t need this array of characters to use on something later, there is no need to save all the file contents in a string, you can use only one character and always assign it to it:
char Xseqpath[90];
sprintf(Xseqpath, "%s/xseqpath", mainfile);
FILE *File1 = fopen("ref.fasta", "r");
char file1char; //1 caracter
int charnumber = 0;
while(fscanf(File1, "%c", &file1char) != EOF) //Salva sobrescrevendo
printf("%c", file1char);
fclose(File1);
return 0;