InternetReadFile() corrupting donwloads C

Posted by Lienau on Stack Overflow See other posts from Stack Overflow or by Lienau
Published on 2010-05-18T00:26:52Z Indexed on 2010/05/18 0:30 UTC
Read the original article Hit count: 523

Filed under:
|

I'm able to download text documents (.html, .txt, etc) but I can't download images or exe's. I'm pretty sure that this is because I'm using a char, and thoes files are binary. I know that in C# I would use a byte. But what data-type would I use in this case?

    char buffer[1];
    DWORD dwRead;
    FILE * pFile;
    pFile = fopen(file,"w");
    while (InternetReadFile(hRequest, buffer, 1, &dwRead))
    {
        if(dwRead != 1) break;
        fprintf(pFile,"%s",buffer);
    }
    fclose(pFile);

© Stack Overflow or respective owner

Related posts about c

    Related posts about binary