You need to increase the size of the first dimension of thearray. I changed it from 500 to 700 and the weird ASCII characters go away.
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
int main()
{
FILE *fin;
char k,thearray[500][50];
int i=0,j=0;
fin = fopen("triples.txt", "rb");
while(!feof(fin))
{
k = fgetc(fin);
//printf("%c %d %d\n", k,i,j);
if(k == '#')
{
i++;
j=0;
}
if(isdigit(k) != 0 || k == ',')
{
thearray[i][j] = k;
//printf("%c", thearray[i][j]);
j++;
}
else
{
continue;
}
}
for(j=0;j<i;j++)
{
printf("%s\n", thearray[j]);
}
return 0;
}