/* * leb36 - little endian, base 36 increment exercise. 27 aug 2003. * * feel free to cut and paste this code as you wish. */ #include int main( int argc, char **argv ) { FILE * fi; char num[ 3 ]; char i; fi = fopen( "xx36", "r+" ); /* (the file "xx36" needs to exist and have been * initialized to have "000" as the first three * characters before you run this program.) */ fread( num, 1, 3, fi ); for ( i = 0; i < 3; i++ ) { if ( num[ i ] == 'z' ) { num[ i ] = '0'; } else { if ( num[ i ] == '9' ) { num[ i ] = 'a'; } else { num[ i ]++; } break; } } fseek( fi, 0, SEEK_SET ); fwrite( num, 1, 3, fi ); return 0; }