A
A
Alexander2018-08-20 21:08:35
C++ / C#
Alexander, 2018-08-20 21:08:35

How to translate a piece of Python3 code into C++?

There is a function that returns information about an mp3 file

def getTagValue(path, name):
        with open(path, "rb") as file:
            file.seek(-128, 2)
            if file.read(3).decode("cp1251") == 'TAG':
                title = file.read(30).decode("cp1251")
                artist = file.read(30).decode("cp1251")
                album =  file.read(30).decode("cp1251")
                year =   file.read(4).decode("cp1251")
                comment = file.read(30).decode("cp1251")
            if name == "title":
                return title
            elif name ==  "artist":
                return artist
            elif name ==  "album":
                return album
            elif name ==  "year":
                return year
            elif name == "comment":
                return comment
            else:
                return

How it will look like in C++
That's how I started, things don't go any further :(
char* getTagValue(char* path, char* name){
        file = fopen(path, "rb");

    }

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question