document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. /*
  2.     This program replaces the Tab character by an input number of spaces.
  3.     Date: 110510, Tue 10 May 2011 11:29:02 AM IST
  4. */
  5.  
  6. #include <stdio.h>
  7. #include <string.h>
  8. #include <stdlib.h>
  9.  
  10. int main(int argc, char *argv[]) {
  11.     int ch, tab=\'\\t\';
  12.     char replace[32+1];    /* who would require 32+ width Tab !! */
  13.  
  14.     strcpy(replace,"    ");
  15.     if (argc==2) {
  16.         int c=atoi(argv[1]), i;
  17.         if (c<=0 || c>32) {
  18.             puts("argument should be a number >0 and <=32");
  19.             exit(0);
  20.         }
  21.         for (i=0; i<c; ++i)
  22.             replace[i]=\' \';
  23.         replace[i]=\'\\0\';
  24.     }
  25.     else if (argc>=3)  {
  26.         puts("usage: replaceTab <#_of_spaces>");
  27.         exit(0);
  28.     }
  29.    
  30.     while ((ch=getchar())!=EOF)
  31.         if (ch==tab)
  32.             printf(replace);
  33.         else
  34.             putchar(ch);
  35.  
  36.     return 0;
  37. }
');