二进制写 [英] binary writes

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

问题描述

你好,


有人可以帮忙吗。


我想用sdtout或者用br做二进制文件写入/>
传递文件名并且我不确定如何在C#中做任何事情 - 我会尽可能快地使用


我已经完成了它在awk中,只是为了看看我的意思,因为代码应该是可以被C#高手理解的。


感谢所有给予的建设性帮助。 />

Hal

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~

###这是在awk中,使用''awk -f thisfile.awk'运行'somefile

BEGIN {

m = 50

for(x = 0; x< m; x ++)

for(y = 0; y< m; y ++)

for(z = 0; z< m; z ++)

printf("%c%c%c",x,y,z)

}

Hello,

Can someone please help.

I want to do some binary writing to files either using sdtout or by
passing a filename and I am unsure how to do either in C# - I would
like it to be as fast as possible.
I have done it in awk, just to see what I mean since the code should
be understandable by a C# whiz.

Thanks for all constructive help given.

Hal
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

### this is in awk, run using ''awk -f thisfile.awk'' somefile
BEGIN {
m=50

for (x=0; x<m; x++)
for(y=0; y<m; y++)
for(z=0; z<m; z++)
printf("%c%c%c",x,y,z)
}

推荐答案

15 Maj,23:11,傻... @ yahoo.com写道:
On 15 Maj, 23:11, silly...@yahoo.com wrote:

您好,


有人可以请他lp。


我想使用sdtout或

传递文件名来对文件进行二进制写入,我不确定如何在C#中执行 - 我会尽可能快地给b $ b。

我用awk做过,只是为了看看我的意思,因为代码应该是

可以被C#高手理解。


感谢所有给予的建设性帮助。


Hal

~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

# ##这是在awk中,使用''awk -f thisfile.awk'运行'somefile

BEGIN {

* * m = 50

* * for(x = 0; X<米; x ++)

* * * for(y = 0; y< m; y ++)

* * * * * for(z = 0; z< m; z ++)

* * * * * * printf("%c%c%c",x,y,z)


} - D?lj citerad文本 -


- Visa citerad文本 -
Hello,

Can someone please help.

I want to do some binary writing to files either using sdtout or by
passing a filename and I am unsure how to do either in C# - I would
like it to be as fast as possible.
I have done it in awk, just to see what I mean since the code should
be understandable by a C# whiz.

Thanks for all constructive help given.

Hal
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

### this is in awk, run using ''awk -f thisfile.awk'' somefile
BEGIN {
* *m=50

* *for (x=0; x<m; x++)
* * * for(y=0; y<m; y++)
* * * * *for(z=0; z<m; z++)
* * * * * * printf("%c%c%c",x,y,z)

}- D?lj citerad text -

- Visa citerad text -



据我所知,所有都是二进制文件,但C#和.net使用不同

各种unicode编码,例如UTF-7,8,16,32

啊哈,仍然不明白,但写了前三位二进制..但是

示例写字符...尝试二进制...


使用系统;


class Test

{

static void Main(){

int m = 50;


for(int x = 0; x
for(int y = 0; y< m; y ++)

for(int z = 0; z< m; z ++)

for(int a = 0; a< 7; a ++)

Console.Write(" {0} {1} {2},",

((x& a)== 0?''0'':''1''),

((y& a)== 0 ?''0'':''1''),

((z& a) == 0?''0'':''1''));

string zz = Console.ReadLine();

}

}


这完全没用,但是二进制写操让我不知道,有没有用awk写的模拟




// CY

As I understand is all writing binary, but C# and .net uses different
sorts of unicode encoding, eg UTF-7,8,16,32

Aha, still don understand but writing the first 3 bits binary.. but
the example writes chars... trying binary...

using System;

class Test
{
static void Main(){
int m = 50;

for (int x=0; x<m; x++)
for(int y=0; y<m; y++)
for(int z=0; z<m; z++)
for(int a=0;a<7;a++)
Console.Write("{0}{1}{2},",
((x & a) == 0 ? ''0'' : ''1''),
((y & a) == 0 ? ''0'' : ''1''),
((z & a) == 0 ? ''0'' : ''1''));
string zz = Console.ReadLine();
}
}

this is totally useless, but binary write eludes me, is there a analog
write in awk?

//CY


On 15 Maj,23:54,christ ... @ gmail.com写道:
On 15 Maj, 23:54, christ...@gmail.com wrote:

在15 Maj,23:11,愚蠢...... @ yahoo.com写道:


On 15 Maj, 23:11, silly...@yahoo.com wrote:



您好,
Hello,


有人可以帮忙。
Can someone please help.


我想使用sdtout或

传递文件名对文件进行二进制写入,我不确定如何在C#中做任何一件事 - 我希望

尽可能快。

我用awk做过,只是为了看看我的意思,因为代码应该

可以被C#高手理解。
I want to do some binary writing to files either using sdtout or by
passing a filename and I am unsure how to do either in C# - I would
like it to be as fast as possible.
I have done it in awk, just to see what I mean since the code should
be understandable by a C# whiz.


感谢所有给予的建设性帮助。
Thanks for all constructive help given.


Hal

~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
Hal
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


###这是在awk中,使用''awk运行-f thisfile.awk''somefile

BEGIN {

* * m = 50
### this is in awk, run using ''awk -f thisfile.awk'' somefile
BEGIN {
* *m=50


* * for(x = 0; x< m; x ++)

* * * for(y = 0; y< m; y ++)

* * * * * for(z = 0; z< m; z ++)

* * * * * * printf("%c%c%c",x,y,z)
* *for (x=0; x<m; x++)
* * * for(y=0; y<m; y++)
* * * * *for(z=0; z<m; z++)
* * * * * * printf("%c%c%c",x,y,z)


}
}



或...


更像C


使用系统;


class测试

{

static void Main(){

int m = 50;


for(int x = 0; x< m; x ++)

for(int y = 0; y< m; y ++)

for(int z = 0; z< m; z ++)

Console.Write(" ; {0} {1}

{2}",Convert.ToChar(x),Convert.To Char(y),Convert.T oChar(z));

}

}

or...

More like C

using System;

class Test
{
static void Main(){
int m = 50;

for (int x=0; x<m; x++)
for(int y=0; y<m; y++)
for(int z=0; z<m; z++)
Console.Write("{0}{1}
{2}",Convert.ToChar(x),Convert.ToChar(y),Convert.T oChar(z));
}
}


%c to我,意思是性格,所以我不知道你是否因为某些原因想要将in $
转换为char。我的注意是int。


int m = 50;

MemoryStream ms = new MemoryStream();

BinaryWriter bw = new BinaryWriter(ms);


for(int x = 0; x< m; ++ x)

{

for(int y = 0; y< m; ++ y)

{

for(int z = 0; z< m; ++ z)

{

bw.Write(x); bw.Write(Y); bw.Write(z);

}

}

}


File.WriteAllBytes(

@" c:\软件开发\Output.bin",

ms.ToArray());

" si ******@yahoo.com"写道:
%c to me, means character, so I don''t know if you wanted to convert the ints
to char for some reason. I went with the ints being ints.

int m = 50;
MemoryStream ms = new MemoryStream();
BinaryWriter bw = new BinaryWriter(ms);

for (int x = 0; x < m; ++x)
{
for (int y = 0; y < m; ++y)
{
for (int z = 0; z < m; ++z)
{
bw.Write(x); bw.Write(y); bw.Write(z);
}
}
}

File.WriteAllBytes(
@"c:\Software Development\Output.bin",
ms.ToArray());
"si******@yahoo.com" wrote:

您好,


有人可以帮忙。


我想要使用sdtout或通过

传递文件名来对文件进行二进制写入,我不确定如何在C#中执行 - 我会

就像它一样尽可能快。

我已经用awk完成了,只是为了看看我的意思,因为代码应该可以被C#高手理解。


感谢所有给予的建设性帮助。


Hal

~~~~~~~~~~~~~~~~~ ~~~~~~~~~

###这是在awk中,使用''awk -f thisfile运行.awk''somefile

BEGIN {

m = 50

for(x = 0; x< m; x ++)

for(y = 0; y< m; y ++)

for(z = 0; z< m; z ++)

printf(" ;%c%c%c",x,y,z)

}
Hello,

Can someone please help.

I want to do some binary writing to files either using sdtout or by
passing a filename and I am unsure how to do either in C# - I would
like it to be as fast as possible.
I have done it in awk, just to see what I mean since the code should
be understandable by a C# whiz.

Thanks for all constructive help given.

Hal
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

### this is in awk, run using ''awk -f thisfile.awk'' somefile
BEGIN {
m=50

for (x=0; x<m; x++)
for(y=0; y<m; y++)
for(z=0; z<m; z++)
printf("%c%c%c",x,y,z)
}


这篇关于二进制写的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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