本文介绍了写二进制数据,其大小超过unsinged它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 你好,它又是我了。 i像往常一样实现了DBMS,我需要使用8字节整数作为长度来调用fwrite 要写入的数据(仅在 的情况下,可能会发生大于2 GB的数据)。 问题是fwrite需要一个size_t(一个unsiged) 4字节整数 ),而不是8字节整数。我也不能在_Size和_Count参数之间分配 长度的技巧,因为它们的 乘法也是unsigned int(在fwrite实现中)。 br /> 我的问题是,是否存在任何写入 长度需要8字节整数的数据的IO函数?hello, it''s me again.i was implementing a DBMS, as usual, where i needed to call fwriteusing 8-byte integer as the length of the data to be written ( just incase there is data bigger than 2 GB, which may happen ).The problem is that fwrite takes a size_t ( an unsiged 4-byte integer), not 8-byte integer. i also can''t play the trick of dividing thelength between the _Size and _Count parameters because theirmultiplication is also unsigned int ( in the fwrite implementation ).My question is, does there exist any IO function that writes data whoselength requires 8-byte integer ?推荐答案 当然,在size_t为8字节的系统上。 如果你需要编写的数据超过单个fwrite()调用可以在你的实现中处理 ,你应该可以使用多个fwrite() 来电。假设你有一个64位整数类型(例如,unsigned long long),你可以编写一个简单的包装器函数,根据需要多次调用fwrite() 。 < OT> 你也可以寻找大文件支持。在您的操作系统中 文档。 < / OT> - Keith Thompson(The_Other_Keith) ks***@mib.org < http://www.ghoti.net/~kst> ; 圣地亚哥超级计算机中心< *> < http://users.sdsc.edu/~kst> 我们必须做点什么。这是事情。因此,我们必须这样做。Sure, on systems where size_t is 8 bytes.If you need to write more data than a single fwrite() call can handlein your implementation, you should be able to use multiple fwrite()calls. Assuming you have a 64-bit integer type (e.g., unsigned longlong), you can write a simple wrapper function that invokes fwrite()as many times as necessary.<OT>You might also look for "large file support" in your operating system''sdocumentation.</OT>--Keith Thompson (The_Other_Keith) ks***@mib.org <http://www.ghoti.net/~kst>San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>We must do something. This is something. Therefore, we must do this. 我的操作系统是Windows XP,我认为是大文件关于文件系统的支持是 。 FAT32不支持大于4 GB的文件。但是 NTFS在群集系统中最多可以支持256 TB,否则最多可以支持2 TB 。来源 http://www.windowsitpro.com /Articles...rticleID=27253My operating system is windows XP, i think the large file support isabout the file system. FAT32 can''t support files larger than 4 GB. butNTFS can support up to 256 TB in a clustered system, and up to 2 TBotherwise. source http://www.windowsitpro.com/Articles...rticleID=27253 有可能。但是语言不需要''size_t'' 来获得8个字节的大小。 for(i = 0; i< chunks; ++ i ) fwrite(/ * etc * /); -MikeThere might. But the language doesn''t require ''size_t''to have size of eight bytes.for(i = 0; i < chunks; ++i)fwrite( /* etc */ );-Mike 这篇关于写二进制数据,其大小超过unsinged它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 09-11 02:17