#include #include #include namespace textfile { char *buffer = nullptr; int fsize = 0; int p = 0; const bool open(std::string filename) { FILE *f = fopen(filename.c_str(), "rb"); if (!f) { printf("ERROR AL OBRIR EL ARXIU\n"); return false; } fseek(f, 0, SEEK_END); fsize = ftell(f); fseek(f, 0, SEEK_SET); buffer = (char*)malloc(fsize); fread(buffer, fsize, 1, f); fclose(f); p = 0; return true; } void close() { free(buffer); } std::string getNextToken() { char token[255]; int tpos = 0; // Ignore whitespace while (p32 ) token[tpos++]=buffer[p++]; token[tpos]=0; return std::string(token); } const bool searchToken(std::string token) { while (p