Created
October 14, 2009 23:11
-
-
Save kidd/210478 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
/* | |
* ===================================================================================== | |
* | |
* Filename: textAsFlood.cpp | |
* | |
* Description: "Utility" to help speed reading trainning | |
* | |
* Version: 0.01 | |
* Created: 10/12/2009 11:58:40 PM | |
* Revision: none | |
* Compiler: g++ -o textAsFlood textAsFlood.c | |
* | |
* Author: Raimon Grau Cuscó (rg), raimonster@gmail.com | |
* Company: | |
* Usage: ./textAsFlood textFile | |
* ===================================================================================== | |
*/ | |
#include <stdio.h> | |
//#include "glut.h" | |
#include <iostream> | |
#include <fstream> | |
#include <string> | |
#include <vector> | |
#include <time.h> | |
using namespace std; | |
void Tokenize(const string& str, | |
vector<string>& tokens, | |
const string& delimiters = " ") | |
{ | |
string::size_type lastPos = str.find_first_not_of(delimiters, 0); | |
string::size_type pos = str.find_first_of(delimiters, lastPos); | |
while (string::npos != pos || string::npos != lastPos) | |
{ | |
tokens.push_back(str.substr(lastPos, pos - lastPos)); | |
lastPos = str.find_first_not_of(delimiters, pos); | |
pos = str.find_first_of(delimiters, lastPos); | |
} | |
} | |
int main(int argc, char const* argv[]) | |
{ | |
struct timespec tv,tv2; | |
tv.tv_sec=0; | |
tv.tv_nsec=240000000; | |
ifstream myfile (argv[1]); | |
string line; | |
std::vector<string> vTokens; | |
std::vector<string> vWords; | |
if (myfile.is_open()) { | |
while (!myfile.eof()) { | |
getline(myfile,line); | |
Tokenize(line, vTokens); | |
for (int i = 0; i < vTokens.size(); i+=2) { | |
cout << " \r" ; | |
fflush(stdout); | |
cout << vTokens[i] ; | |
if (vTokens.size()>i+1) { | |
cout << " " << vTokens[i+1]; | |
} | |
fflush(stdout); | |
nanosleep(&tv,&tv2); | |
} | |
vTokens.clear(); | |
} | |
myfile.close(); | |
} | |
else{ | |
cout << "nein"<< endl; | |
} | |
return 0; | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment