Joined
·
837 Posts
Burnt Out....
CAn Anyone tell me why this is spitting out non-numerical or ',' characters?
I want this code to take this and put the numbers in array, seperated by the # signs. i know the arrays are large, but i odn't think that's the problem... when it get's to like the 400th array or "triplet", it begins to attach wierd ascii charaters to the end.
CAn Anyone tell me why this is spitting out non-numerical or ',' characters?
Code:
#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;
}