Created
April 8, 2016 03:33
-
-
Save zvakanaka/7d489259783990f4bb38145ba2bc5f4d to your computer and use it in GitHub Desktop.
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 <iostream> | |
#include <fstream> | |
#include <cstring> | |
using namespace std; | |
int main(int argc, char **argv) | |
{ | |
int i = 0; | |
int color[] = {31, 33, 32, 34, 35}; | |
char fileName[256]; | |
char letter; | |
if (argc < 2) | |
{ | |
cout << "File Name? "; | |
cin.getline(fileName, 256); | |
} | |
else | |
strcpy(fileName, argv[1]); | |
ifstream fin; | |
fin.open(fileName); | |
if (fin.fail()) | |
{ | |
cout << "ERROR: " << fileName << " does not exist\n"; | |
return 1; | |
} | |
i = 0; | |
for (int c = 0; ! fin.eof(); i++) | |
{ | |
if (c > 4) | |
c = 0; | |
fin.get(letter); | |
cout << "\E[1;" << color[c] << "m"; | |
cout << letter; | |
if (letter != ' ') | |
c++; | |
} | |
cout << "\E[0m"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment