Re: Carriage Returns
From: Johan Aurér (aurer_at_axis.com)
Date: 10/09/03
- Next message: Dan Pop: "Re: trapping library calls"
- Previous message: hongky: "Re: The strangest problem...."
- In reply to: Joona I Palaste: "Re: Carriage Returns"
- Next in thread: Joona I Palaste: "Re: Carriage Returns"
- Reply: Joona I Palaste: "Re: Carriage Returns"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 9 Oct 2003 13:39:33 +0200
On Thu, 9 Oct 2003, Joona I Palaste wrote:
> Nimmy <nojunk@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.
-- aurer@axis.com
- Next message: Dan Pop: "Re: trapping library calls"
- Previous message: hongky: "Re: The strangest problem...."
- In reply to: Joona I Palaste: "Re: Carriage Returns"
- Next in thread: Joona I Palaste: "Re: Carriage Returns"
- Reply: Joona I Palaste: "Re: Carriage Returns"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|