Skip to content

fstream decode issues #4

Closed
Closed
@ealfonsov89

Description

I'm getting this error when run the decode with a fstream

terminate called after throwing an instance of 'std::invalid_argument'
  what():  expected string token

this is my main code

#include <fstream>
#include <iostream>
#include <stdio.h>
#include <string>

#include "bencode.hpp"


int main(int argc, char** argv)
{
    std::fstream torrent_file;
    torrent_file.open(argv[1], std::ios_base::in);	
    if (torrent_file.is_open())
    {	
        auto torrent_file_data = bencode::decode(torrent_file);
        torrent_file.close();
    }
    return 0;
}

I'm compiling directly in my code using this command g++ -c "main.cpp" -g -O0 -std=c++20 -Wall -o ../build-Debug/main.cpp.o -I. -I.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions