Tech Support banner

Status
Not open for further replies.
1 - 2 of 2 Posts

·
TSF Team Emeritus
Joined
·
837 Posts
Discussion Starter #1
Burnt Out....

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;
}
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.
 

·
Emeritus
Joined
·
1,131 Posts
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.
 
1 - 2 of 2 Posts
Status
Not open for further replies.
Top