网页资讯视频图片知道文库贴吧地图采购
进入贴吧全吧搜索

 
 
 
日一二三四五六
       
       
       
       
       
       

签到排名:今日本吧第个签到,

本吧因你更精彩,明天继续来努力!

本吧签到人数:0

一键签到
成为超级会员,使用一键签到
一键签到
本月漏签0次!
0
成为超级会员,赠送8张补签卡
如何使用?
点击日历上漏签日期,即可进行补签。
连续签到:天  累计签到:天
0
超级会员单次开通12个月以上,赠送连续签到卡3张
使用连续签到卡
02月17日漏签0天
c语言吧 关注:801,833贴子:4,376,009
  • 看贴

  • 图片

  • 吧主推荐

  • 视频

  • 游戏

  • 8回复贴,共1页
<<返回c语言吧
>0< 加载中...

一道题目。。。

  • 只看楼主
  • 收藏

  • 回复
  • 加成跑
  • 毛蛋
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
对于下述程序,在方式串分别采用"wt"和"wb"运行时,两次生成的文件TEST的长度是
#include <stdio.h>
void main()
{   FILE *fp=fopen("TEST",);
    fputc('A',fp);fputc('\n',fp);
    fputc('B',fp);fputc('\n',fp);
    fputc('C',fp);
    fclose(fp);}
答案是:7字节.5字节


  • 211.136.115.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
求解!


2026-02-17 17:44:44
广告
不感兴趣
开通SVIP免广告
  • 飞天浪子GO
  • 异能力者
    6
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
一个字母为两字节,两外每个字符串是一‘\0'结束的,所以再加一个字节!!


  • 加成跑
  • 毛蛋
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
如果'\n'是一个字节 不正好是7个字节
为什么加'\0'


  • 124.14.102.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
呵呵,3L只不过是在胡说八道,你还真信了


  • 加成跑
  • 毛蛋
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
回复:5楼
求正解???


  • 郭宛人吹吹嘘k
  • 毛蛋
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
"w"
Opens an empty file for writing. If the given file exists, its contents are destroyed.
t
Open in text (translated) mode. In this mode, CTRL+Z is interpreted as an end-of-file character on input. In files opened for reading/writing with "a+", fopen checks for a CTRL+Z at the end of the file and removes it, if possible. This is done because using fseek and ftell to move within a file that ends with a CTRL+Z, may cause fseek to behave improperly near the end of the file.
Also, in text mode, carriage return–linefeed combinations are translated into single linefeeds on input, and linefeed characters are translated to carriage return–linefeed combinations on output. When a Unicode stream-I/O function operates in text mode (the default), the source or destination stream is assumed to be a sequence of multibyte characters. Therefore, the Unicode stream-input functions convert multibyte characters to wide characters. For the same reason, the Unicode stream-output functions convert wide characters to multibyte characters.
b
Open in binary (untranslated) mode; translations involving carriage-return and linefeed characters are suppressed.
If t or b is not given in mode, the default translation mode is defined by the global variable _fmode. If t or b is prefixed to the argument, the function fails and returns NULL.
For more information about using text and binary modes in Unicode and multibyte stream-I/O, see Text and Binary Mode File I/O and Unicode Stream I/O in Text and Binary Modes.
----------------------------------------------------
Also, in text mode, carriage return–linefeed combinations are translated into single linefeeds on input, and linefeed characters are translated to carriage return–linefeed combinations on output.
这个才是正解,为啥wt模式下输出是7个字节


  • 孤单ˉ背影
  • 毛蛋
    1
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
7L..
你太了风了..


2026-02-17 17:38:44
广告
不感兴趣
开通SVIP免广告
  • 220.181.34.*
快试试吧,
可以对自己使用挽尊卡咯~
◆
◆
该楼层疑似违规已被系统折叠 隐藏此楼查看此楼
回复:6楼
b和t分别表示二进制和文本,说起来超悬乎,其实只有\n\r转\n这点小猫腻


登录百度账号

扫二维码下载贴吧客户端

下载贴吧APP
看高清直播、视频!
  • 贴吧页面意见反馈
  • 违规贴吧举报反馈通道
  • 贴吧违规信息处理公示
  • 8回复贴,共1页
<<返回c语言吧
分享到:
©2026 Baidu贴吧协议|隐私政策|吧主制度|意见反馈|网络谣言警示