#include 
#include 
#include 
#include 
int terminate(char *error)
{
    std::cout << error << "\n";
    system("pause");
    exit(1);
}
void substr(char *tag, int from, int to)
{
    for(int i = from; i <= to; i++)
    {
        for(int x = 0; x <= 50000000; x++); // create a type writer effect
        std::cout << tag[i];
    }
    std::cout << '\n';
}
char *getId3(std::string path)
{
    FILE *soundFile;
    char id3Tag[128];
    soundFile = fopen(path.c_str(), "r");
    if (soundFile == NULL)
        terminate("Could not open file.");
    if (!fseek(soundFile, -128, SEEK_END))
    {
        fgets(id3Tag, 128, soundFile);
        
        // read on id3.org
        substr(id3Tag, 33, 60); // the artist
        substr(id3Tag, 3, 30); // the title
    }
    else
    {
        terminate("Could not seek file.");
    }
    fclose(soundFile);
    return id3Tag;
}
int main()
{
    std::cout << "Id3Finder by Nicklas" << '\n' << '\n';
    std::string myPath;
    
    std::cout << "input: ";
    
    std::getline(std::cin, myPath);
    std::cout << "output:" << '\n';
    
    getId3(myPath);
    
    terminate("\nThat was the id3tag for the requested file.\n");
}