English 中文(简体)
因特网ReadFile(C)腐败地下载
原标题:InternetReadFile() corrupting downloads in C
  • 时间:2010-05-18 00:26:52
  •  标签:
  • c
  • binary

能够下载文件(html,txt等),但我可以下载图像或外观。 我确信,这是因为Im使用果园,这些档案是双手的。 我知道,在“C# I”中,将使用一种 by。 但在这种情况下我会使用何种数据类型?

    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);
最佳回答

你们的问题不是char,而是用百分.。 。 当双元数据库具有<条码><>>>>(NUL)特性时,印本将阻止当时的产出数据。

在此情况下,请使用<代码>fwrite。

在Windows,在开启双亲档案时,还必须使用<条码>b查询器。

问题回答

由于你是在没有被终止的缓冲器(由于其尺寸为1)中逐字阅读的,因此,你需要用<代码>%c<>/code>作为显示或使用<代码>的表格(>putc (buffer[0], pFile)的一段时间逐年输出。 目前,你很容易受到缓冲外溢的影响(例如,可能发生坏事!)

如果你在视窗平台上,以双轨方式打开文档将是一个好主意;由于双亲和文字模式之间不存在任何区别,因此不会对“九”造成伤害。





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签