Slide 7.4: EnterBook.cpp
Slide 7.6: itoa.h
Home

FixedLen.h


To easily manage the linked list, each of the data head/length/offsets/links/last takes five bytes. The FixedLen(int n, char* str, int s) function puts the integer n into a string str of a length s.

 ~wenchen/public_html/cgi-bin/351/week7/FixedLen.h 
#include  <cstring>
  using namespace std;

#include  "itoa.h"

char*  FixedLen( int n, char* str, int s ) {
  int  len;

  itoa( n, str );
  len = strlen( str );
  for ( ;  s > len;  len++ )  str[len] = ' ';
  str[len] = '\0';
  return( str );
}