Last active
August 29, 2015 14:04
-
-
Save Learath2/5ee704b4b867d459fc00 to your computer and use it in GitHub Desktop.
K&R2 Exercise 1-20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#define TABSTOP 8 | |
int mod(float, float); | |
int main() | |
{ | |
int c, i, cc; | |
cc = 0; | |
while((c = getchar()) != EOF){ | |
if(c != '\t'){ | |
if(c == '\n') | |
cc = -1; | |
putchar(c); | |
++cc; | |
} | |
else{ | |
do | |
putchar(' '); | |
while(mod(++cc, TABSTOP) != 0); | |
} | |
} | |
} | |
int mod(float dividend, float divisor) | |
{ | |
int division; | |
division = dividend/divisor; | |
return dividend - (division * divisor); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment