Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdlib.h>
- #include <stdio.h>
- #include <windows.h>
- enum ConsoleColor
- {
- Black = 0,
- Blue = 1,
- Green = 2,
- Cyan = 3,
- Red = 4,
- Magenta = 5,
- Brown = 6,
- LightGray = 7,
- DarkGray = 8,
- LightBlue = 9,
- LightGreen = 10,
- LightCyan = 11,
- LightRed = 12,
- LightMagenta = 13,
- Yellow = 14,
- White = 15
- };
- bool compare(char c){
- char s[] = " \t\n(){}+=-/*&%x;,";
- for(int i = 0; s[i]; i++)
- if(c == s[i]) return true;
- return false || (c == EOF);
- }
- int main(int argc, char **argv){
- char ch;
- bool free = true;
- FILE *fIN;
- //SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), (WORD)(White));
- if(argc < 2)
- fIN = fopen("input.c", "r");
- else
- fIN = fopen(argv[1], "r");
- //some octals: 023 0df 0123 0x123 123 25
- while((ch = getc(fIN)) != EOF){
- if(!free){
- if(compare(ch))
- free = true;
- putchar(ch);
- }else{
- if(ch == '0'){
- if(!compare(ch = getc(fIN))){
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), (WORD)(Brown));
- putchar('0'); putchar(ch);
- while(!compare(ch = getc(fIN)))
- putchar(ch);
- SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), (WORD)(White));
- if(ch != EOF) putchar(ch);
- }
- }else{
- free = false;
- putchar(ch);
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement