Hello Every1,
I am stuck at the very starting step of my code.
I have to read a file which looks like this
#city1 #city2 #distance
delhi mumbai 2005
calicut goa 3294
I wan to read these in different arrays.
I wrote something like this
Code:
char *pC1 = NULL,*pC2= NULL;
float *pC3;
FILE *fp;
fp = fopen("String_DNA_CombinedScore.txt","r");
int i, edges=0;
char name[10];
while(fgets(names,10,fp2) != NULL)
{
count++;
}
printf("The total number of cities: %d\n", count);
pC1 = (char*) calloc(edges, sizeof(char));
pC2 = (char*) calloc(edges, sizeof(char));
pC3 = (int*) calloc(edges, sizeof(int));
rewind(fp2);
for (i=0;i<count;i++)
{
fscanf(fp,"%s %s %f", &pC1[i], &pC2[i], &pC3[i]);
printf("%c%c %f \n", pC1[i], pC2[i], pC3[i]);
}
return edges;
}
thanks