Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* The utility reads text from stdin and prepends each line with a
- * number. If a line contains a tab character, the tab character gets
- * replaced with an arrow character. */
- #include <stdio.h>
- #define MAX_BUFF_SIZE 65536
- int main()
- {
- char buffer[MAX_BUFF_SIZE] = {};
- char *buff_ptr;
- int number = 1;
- int counter = 0;
- buff_ptr = fgets(buffer, MAX_BUFF_SIZE - 1, stdin);
- while(buff_ptr)
- {
- printf("%d. ", number);
- while(buffer[counter] != 0)
- {
- if(buffer[counter] == '\t')
- printf(" → ");
- else
- (void) putc(buffer[counter], stdout);
- counter += 1;
- }
- counter = 0;
- buff_ptr = fgets(buffer, MAX_BUFF_SIZE - 1, stdin);
- number += 1;
- }
- return(0);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement