什么是在的fopen r和RB之间的差异 [英] what's the differences between r and rb in fopen

查看:524
本文介绍了什么是在的fopen r和RB之间的差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用C中的fopen试过了,第二个参数是开放模式。这两种模式r和RB往往混淆了我很多。似乎它们是相同的。但有时它是更好地使用RB。那么,为什么R存在吗?
解释给我详细或例子。
谢谢。

I tried using fopen in C, the second parameter is the open mode. The two modes "r" and "rb" tend to confuse me a lot. It seems they are the same. But sometimes it is better to use "rb". So, why does "r" exist? Explain it to me in detail or with examples. Thank You.

推荐答案

您应该使用R打开文本文件。不同的操作系统有存储文本的方式略有不同,这将执行正确的翻译,这样你就不需要了解本地操作系统的特质。例如,你就会知道,新行总是显示为一个简单的\\ n,无论code运行在何处。

You should use "r" for opening text files. Different operating systems have slightly different ways of storing text, and this will perform the correct translations so that you don't need to know about the idiosyncracies of the local operating system. For example, you will know that newlines will always appear as a simple "\n", regardless of where the code runs.

您应该使用RB如果你打开​​非文本文件,因为在这种情况下,翻译是不恰当的。

You should use "rb" if you're opening non-text files, because in this case, the translations are not appropriate.

这篇关于什么是在的fopen r和RB之间的差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆