C Programming Homework #4: Detabification

Due: Monday, February 15, 2016

Read Example #2 in my C tutorial.

  1. Write a filter program that replaces tabs in a file with an appropriate number of spaces. Use a tab stop setting of every 8 columns. Be aware that the program can't simply replace a tab character with 8 spaces. The number of spaces required depends on how far it is to the next tab stop. You will need to track the current position in the line and, when encountering a tab character, compute the distance to the tab stop.

    Use the following skeleton as a starting point:

      #include <stdio.h>
      
      int main( void )
      {
          int ch;
    
          while( (ch = getchar()) != EOF ) {
              // Bulk of the program logic goes here.
          }
          return 0;
      }
    

Submit your program to Moodle (the .c file). Be sure it includes a comment block at the top that includes your name, the name of the file, the date, and a brief description of what the program does..


Last Revised: 2016-02-09
© Copyright 2016 by Peter C. Chapin <PChapin@vtc.vsc.edu>