ok what im trying to do is to combine 3 bits of code that are exactly the same except for what the read in character is passed into.
firstly i read in from the file to a temp 'z', then do some checking which is all the same, and then i want to move it into the struct (but i want it to go to 3 different multidimensional arrays to store).
i cant figure out what to pass and how so to put the 1st in 'street_name', 2nd in 'street_type', & 3rd in 'suburb_name'.
check out my code and help if u can, thanx.
DECLARATION:
Code:
void readString(BOOK *fptr, char z, FILE *bfil, int a);
CALL TO FUNCTION:
Code:
readString(fptr, z, batch_in_file, a);
FUNCTION:
Code:
void readString(BOOK *fptr, char z, FILE *bfil, int a)
{
int b = 0; /* Declare temporary counting variables */
count = 0; /* Reset counter to read incoming string */
rester(); /* Call to reset word test variables */
for (b = 0; b < STRING_MAX_SIZE; b++) /* Run loop until maximum string size */
{ /* Start for loop */
if(ended == TRUE) /* Check if end of word has been reached */
{ /* Start if statement */
break; /* Break from for loop if at end of word */
} /* End if statement */
z = fgetc(bfil); /* Gather character from file to temporary variable */
if((z == ' ') && (started == FALSE)) /* Check if read in character is a space */
{ /* Start if statement */
b--; /* Reset counter back one to allow space */
} /* End if statement */
else /* Else read in character is not a space */
{ /* Start else statement */
started = TRUE; /* Set started to true if word has begun */
if((z == ' ') && (started == TRUE)) /* Check if character is a space and word has started */
{ /* Start if statement */
ended = TRUE; /* Set end to true if at end of word */
} /* End if statement */
else /* Else character is letter in word */
{ /* Start else statement */
count++; /* Add one to string size counter */
fptr->street_name[a][b] = z; /* Move read in character into struct */
} /* End else statement */
} /* End else statement */
} /* End for loop */
}
what the heck do i put in the bolded bits so i can just call it and pass in where i want it to go. thanx again.