回车 [英] Carriage Returns

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

问题描述




我有一个数据文件,我想删除回车。任何人有任何C

代码/程序这样做?我正在使用Windows XP机器.....我不能让b $ b有权访问UNIX机器。但是我需要将这个数据文件发送到Unix

机器上,一旦我从我的XP机器上移除了回车架。


谢谢

解决方案

Nimmy< no **** @ please.com>潦草地写道:


我有一个数据文件,我想删除回车。任何人都有任何C />代码/程序这样做?我正在使用Windows XP机器.....我不能访问UNIX机器。但是我需要将这个数据文件发送到Unix
机器上,一旦我从XP机器上移除了回车架。




这里是一个简单的过滤器 - 类型程序。


#include< stdio.h>

int main(void){

int cr ='' \r ''; / *回车代码* /

int c;

while((c = getchar())!= EOF){

if(c!= cr){

putchar(c);

}

}

返回0;

}


只需从要删除的文件中重定向stdin

返回并将stdout重定向到新文件。


-

/ - Joona Palaste(pa*****@cc.helsinki.fi)--------- ------------------ \

| 飞翔的柠檬树中的金鸡王G ++ FR FW + M-#108 D + ADA N +++ |

| http://www.helsinki.fi/~palaste W ++ B OP + |

\ -----------------------------------------芬兰的规则! ------------ /

你会得到瘟疫。

- 蒙哥马利伯恩斯


2003年10月9日星期四,Joona I Palaste写道:

Nimmy< no **** @ please.com>潦草地写道:


我有一个数据文件,我想删除回车。任何人都有任何C />代码/程序这样做?我正在使用Windows XP机器.....我不能访问UNIX机器。但是,一旦我从XP机器上移除了回车,我就需要将这个数据文件发送到Unix
机器。



这是一个简单的过滤器类型程序。 br />
#include< stdio.h>
int main(void){
int cr =''\ r''; / *回车代码* /
int c;
while((c = getchar())!= EOF){
if(c!= cr){
putchar(c);
}
}
返回0;
}
只需从要删除的文件中重定向stdin
返回并将stdout重定向到新文件。




否,默认情况下,stdin和stdout都是文本流。标准不强制要求文本流的字符与

外部表示之间的一对一
对应关系。你需要

使用二进制流。


-
au***@axis.com


JohanAurér< au *** @ axis.com>潦草地写道:

2003年10月9日星期四,Joona I Palaste写道:

Nimmy< no **** @ please.com>潦草地写下:

>

>我有一个数据文件,我想删除回车。任何人都有任何C
>代码/程序这样做?我正在使用Windows XP机器......我不是
>有权访问UNIX机器。但我需要将此数据文件发送到Unix
>机器一旦我从我的XP机器上取下托架回收器。



这是一个简单的过滤器类型程序。

#include< stdio.h>
int main(void){
int cr =''\ r''; / *回车代码* /
int c;
while((c = getchar())!= EOF){
if(c!= cr){
putchar(c);
}
}
返回0;
}
只需从要删除的文件中重定向stdin
返回并将stdout重定向到新文件。



否,默认情况下,stdin和stdout都是文本流。标准不强制要求文本流的字符与外部表示之间的一对一对应关系。你需要使用二进制流。




哎呀。只为我在UNIX上测试这个程序提供服务,

不区分文本和二进制流。感谢

更正。


-

/ - Joona Palaste(pa ***** @ cc。 helsinki.fi)--------------------------- \

| 飞翔的柠檬树中的金鸡王G ++ FR FW + M-#108 D + ADA N +++ |

| http://www.helsinki.fi/~palaste W ++ B OP + |

\ -----------------------------------------芬兰的规则! ------------ /

B-but Angus!你是龙!

- 米老鼠


Hi,

I have a data file and I want to remove Carriage returns. Any one has any C
code/program which does this? I am working on Windows XP machine.....I don''t
have access to UNIX machine. But I need to send this data file to the Unix
machine once I remove the carriage retunrns from my XP machine.

Thanks

解决方案

Nimmy <no****@please.com> scribbled the following:

Hi, I have a data file and I want to remove Carriage returns. Any one has any C
code/program which does this? I am working on Windows XP machine.....I don''t
have access to UNIX machine. But I need to send this data file to the Unix
machine once I remove the carriage retunrns from my XP machine.



Here''s a simple filter-type program.

#include <stdio.h>
int main(void) {
int cr = ''\r''; /* the code for carriage return */
int c;
while ((c = getchar()) != EOF) {
if (c != cr) {
putchar(c);
}
}
return 0;
}

Simply redirect stdin from the file you want to remove carriage
returns from and redirect stdout to the new file.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"You will be given the plague."
- Montgomery Burns


On Thu, 9 Oct 2003, Joona I Palaste wrote:

Nimmy <no****@please.com> scribbled the following:

Hi,


I have a data file and I want to remove Carriage returns. Any one has any C
code/program which does this? I am working on Windows XP machine.....I don''t
have access to UNIX machine. But I need to send this data file to the Unix
machine once I remove the carriage retunrns from my XP machine.



Here''s a simple filter-type program.

#include <stdio.h>
int main(void) {
int cr = ''\r''; /* the code for carriage return */
int c;
while ((c = getchar()) != EOF) {
if (c != cr) {
putchar(c);
}
}
return 0;
}

Simply redirect stdin from the file you want to remove carriage
returns from and redirect stdout to the new file.



No, both stdin and stdout are text streams by default. A one-to-one
correspondence between the characters of a text stream and the
external representation is not mandated by the standard. You need to
use binary streams.

--
au***@axis.com


Johan Aurér <au***@axis.com> scribbled the following:

On Thu, 9 Oct 2003, Joona I Palaste wrote:

Nimmy <no****@please.com> scribbled the following:

> Hi,

> I have a data file and I want to remove Carriage returns. Any one has any C
> code/program which does this? I am working on Windows XP machine.....I don''t
> have access to UNIX machine. But I need to send this data file to the Unix
> machine once I remove the carriage retunrns from my XP machine.



Here''s a simple filter-type program.

#include <stdio.h>
int main(void) {
int cr = ''\r''; /* the code for carriage return */
int c;
while ((c = getchar()) != EOF) {
if (c != cr) {
putchar(c);
}
}
return 0;
}

Simply redirect stdin from the file you want to remove carriage
returns from and redirect stdout to the new file.


No, both stdin and stdout are text streams by default. A one-to-one
correspondence between the characters of a text stream and the
external representation is not mandated by the standard. You need to
use binary streams.



Whoops. Serves me right for only ever testing this program on UNIX,
which makes no distinction between text and binary streams. Thanks for
the correction.

--
/-- Joona Palaste (pa*****@cc.helsinki.fi) ---------------------------\
| Kingpriest of "The Flying Lemon Tree" G++ FR FW+ M- #108 D+ ADA N+++|
| http://www.helsinki.fi/~palaste W++ B OP+ |
\----------------------------------------- Finland rules! ------------/
"B-but Angus! You''re a dragon!"
- Mickey Mouse


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

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