i got stuck on another subject here:
i got a file of format:
1;Name One
2;Name Two
etc...
i have to read that, and put it into:
the numeric part in an int array1[x]
and the name part into char array2[x][y]
so this way i can reference from array1 to array2... it's not only a double array, it's also paralel arrays.
now i got this and it doesn't work right... i can't find a symilar example anywhere:
Code:
void prep_product_report(){
FILE *fp;
int i;
int prod_codes[12];
char prod_desc[12][30];
int salesman_no[10];
char salesman_name[10][30];
if((fp = fopen("salespeople.dat", "r")) == NULL)
printf("Can not open salespeople.dat file.\n");
else{
rewind(fp);
for(i = 0; i<10; i++){
fscanf(fp, "%d;%s", salesman_no, salesman_name[i]);
}
fclose(fp);
}
if((fp = fopen("products.dat", "r")) == NULL)
printf("Can not open products.dat file.\n");
else{
rewind(fp);
for(i = 0; i<12; i++){
fscanf(fp, "%*d;%s", prod_codes, prod_desc[i]);
}
fclose(fp);
}
product_report(prod_codes, prod_desc, salesman_no, salesman_name);
}
problem is i am forced to create a function declared:
Code:
void product_report(int prod_codes[ ], char prod_desc[ ][30], int salesman_no[ ], char salesman_name[ ][30]);
any help much appreciated.
Thank you!