src/genericFunctions.c
extern int readNum (unsigned short int numLength,
                      unsigned short int *number,
                      FILE *p_fp)
{
  char ch;
  int idValue = 0;
  int place = 10;
  int i;

  for (i=0; i<numLength-2; i++) {
    place *= 10;
  }

  for (i=0; i<numLength; i++, place/=10)
  {
    if (!(isdigit (ch = fgetc(p_fp))))
    {
      return 0;
    }
    /*Convert character to integer value and add to total value*/
    idValue += (ch-'0')*place;
  }
  *number = idValue;
  return 1;
}
/*
Function:
  Reads a number from a file, from a specified number of characters.

Parameters:
  numLength: Number of characters to evaluate for the number
  number: An int pointer to send the output to
  p_fp: The file pointer to read the number from

Returns:
  1 if successful
  0 if not
*/
Reads a number from a file, from a specified number of characters.

Number of characters to evaluate for the number
number: An int pointer to send the output to
p_fp: The file pointer to read the number from

1 if successful
0 if not
Reads a number from a file from a specified number of characters . Number of characters to evaluate for the number number : An int pointer to send the output to p_fp : The file pointer to read the number from 1 if successful 0 if not
extern int readNum (unsigned short int numLength,
                      unsigned short int *number,
                      FILE *p_fp)
{
  char ch;
  int idValue = 0;
  int place = 10;
  int i;
  for (i=0; i<numLength-2; i++) {
    place *= 10;
  }
  for (i=0; i<numLength; i++, place/=10)
  {
    if (!(isdigit (ch = fgetc(p_fp))))
    {
      return 0;
    }
    idValue += (ch-'0')*place;
  }
  *number = idValue;
  return 1;
}
extern int readNum ( unsigned short int numLength , unsigned short int * number , FILE * p_fp ) { char ch ; int idValue = 0 ; int place = 10 ; int i ; for ( i = 0 ; i < numLength - 2 ; i ++ ) { place *= 10 ; } for ( i = 0 ; i < numLength ; i ++ , place /= 10 ) { if ( ! ( isdigit ( ch = fgetc ( p_fp ) ) ) ) { return 0 ; } idValue += ( ch - ' ' ) * place ; } * number = idValue ; return 1 ; }
Function:
Reads a number from a file, from a specified number of characters.
Function : Reads a number from a file from a specified number of characters .
/*Convert character to integer value and add to total value*/