Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* head */
- #include <stdio.h>
- #define LINEMAX 1000
- #define TABSTOP 8
- /* external variables */
- char str[LINEMAX];
- int charcount = 0;
- /* function prototypes */
- void getstr(void);
- void putstr(void);
- /* body */
- main(){
- int n = 0;
- int stop;
- getstr();
- putstr();
- }
- /* function definitions */
- void getstr(void){
- char c;
- int n;
- for( n = 0; ( c = getchar() ) != EOF && c != '\n'; ++n ){
- str[n] = c;
- }
- if( c = '\n' ){
- str[n] = c;
- ++n;
- }
- str[n] = '\0';
- }
- void putstr(void){
- int n;
- char c;
- for( n = 0; ( c = str[n] ) != '\0'; ++n ){
- int space = ( TABSTOP - ( charcount % TABSTOP ) );
- int loop;
- if( c == '\t' ){
- for( loop = 0; loop < space; ++loop){
- putchar(' ');
- }
- charcount = charcount + space;
- /* putchar('\t');
- printf("%d,%d", charcount, space );
- */ }
- else{
- putchar(str[n]);
- ++charcount;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment