/* * Program: Global Communicator II - broadcaster dara converter * Programmer: Robert John Morton UK-YE572246C * Date: Tue 22 Sep 2020 From the directory in which broadcasters.c resides: to compile: gcc broadcasters.c -o broadcasters */ #include // input output to/from the console and keyboard #include // standard functions for the 'C' language void main() { FILE *FI = fopen("broadcasters.txt","rb"); // open the input file FILE *HS = fopen("broadcasters.dat","wb"); // open the output file fputc('1',HS); // known to be 176 broadcasters fputc('7',HS); fputc('6',HS); for(int i = 3; i < 32; i++) fputc('\0',HS); for(int i = 0; i < 176; i++) { int x = 0, c; while( // While the next character is not a (c = fgetc(FI)) != '\n' // carriage-return [end of line] and && x < 32) { // 'c' character No 31 [the last] or below fputc(c,HS); // write 'c' to the output .dat file x++; // and increment to next character number } if(x < 31) // less than 32 bytes written to output file for(int k = x; k < 32; k++) fputc('\0',HS); // fill the rest of the record with spaces } fclose(FI); fclose(HS); }