在c中流io [英] stream io in c

查看:75
本文介绍了在c中流io的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个问题出现在一个常见的C扩展语法中,我希望

来回答如何在C中解决它,因为我认为解决方案不到

十行和一个我可以通过gdb,我的不良调试器一步一步。


% - 通过Fortran写$ 00- $ FF

% -

% - 我需要一个重要的项目来写出简单的

% - $ 00到$ FF范围内的unsigned-char值,

% - 没有添加任何无关数据:

% -

% - 打开:打开文件原始8位二进制输出

% - 顺序写入;没什么特别的。

% - 写:写出单个无符号的8位值,没有

% - 无关的任何数据

% - (单个值导致单个值输出

% - file)

% - close:关闭文件,不附加任何无关数据。

% - 大小:文件大小只是写入的实际值的数量!


我认为c中的解决方案可以像实例化循环一样简单

0到255,putchar''在循环体中,然后将输出重定向到文件。如果文件的创建来自源代码,我怀疑它是否必须处于''rb'模式。


但我不知道不知道。我希望使用8位设备,所以我最好能得到一个好的

手柄。谢谢和欢呼,

-

财富 - 任何收入比一年至少多一百美元的收入。是妻子的妹妹的丈夫。 6

HL Mencken

解决方案

00 -


FF via Fortran

% -

% - 我需要一个重要的项目来写出简单的

% - 范围内的unsigned-char值

00到


A question came up in a syntax which is a common C extension, and I wanted
to answer how to solve it in C, as I believe that the solution is less than
ten lines and one that I could step through with gdb, my untoward debugger.

%- Writing $00-$FF via Fortran
%-
%- I am in need for an important project to write out simple
%- unsigned-char values in the range $00 through $FF,
%- without any extraneous data being added:
%-
%- open: Open the file for "raw 8-bit binary output"
%- Sequential writes; nothing fancy.
%- write: Write out individual unsigned 8-bit values with no
%- extraneous data whatsoever being involved
%- (a single value results in a single value going to output
%- file)
%- close: Close the file with no extraneous data being appended.
%- Size: File size is only the number of actual values written!

I think the solution in c could be as easy as instantiating a loop from
zero to 255, putchar''ing in the body of the loop, then redirecting output
to a file. If the creation of the file comes from the source, I suspect it
would have to be in ''rb'' mode.

But I don''t know. I''m hoping to use 8-bit devices, so I better get a good
handle on it. Thanks and cheers,
--
Wealth - any income that is at least one hundred dollars more a year than
the income of one''s wife''s sister''s husband. 6
H. L. Mencken

解决方案

00-


FF via Fortran
%-
%- I am in need for an important project to write out simple
%- unsigned-char values in the range


00 through


这篇关于在c中流io的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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