comp.lang.c
[Top] [All Lists]

Re: creating a testfile for catv

Subject: Re: creating a testfile for catv
From: Barry Schwarz
Date: Mon, 31 Mar 2008 02:22:50 -0700
Newsgroups: comp.lang.c

On Sun, 30 Mar 2008 02:22:25 -0700, "c gordon liddy" <c@xxxxxxxxxxxxx>
wrote:

>What follows purports to be a soln for K&R 8-1 that prints bitshifted 
>control chars and non-ascii chars:
>

snip code copied from earlier message thread

Why did you change the subject of the message and post the code again?
See the comments in the putchar thread.

>// gcc -o catv catv4.c
>// catv text24.txt >text43.txt
>
>Abridged output from text43 is:
>^JTarget: i386-pc-mingw32^J
>
>My guess is that J is what you get when you add octal 0100 to a carriage 
>return.  Am I correct to think that the first 32 chars are control chars? 

On an ASCII system, \n (as your program sees it, not as it is stored
in the file) is 0xoa which has a decimal representation of 10.

>DEL appears to be 117 as well.

You meant \177?

>
>How would I populate a file containing non-ascii and ctrl chars for test 
>purposes? (Does anyone have one?)

Open a file for output and try 
     int i;
     for (i = 0; i <= UCHAR_MAX; i++)
          fputc(i,fp);
then close the file.


Remove del for email

<Prev in Thread] Current Thread [Next in Thread>
Privacy Policy