Wierd output instead of 0s and 1s
From: Sathyaish (VisualBasicLearner_at_yahoo.com)
Date: 03/01/04
- Next message: Joona I Palaste: "Re: Elementary questions from a beginner"
- Previous message: CBFalconer: "Re: In and Out on port space within C - any standard?"
- Next in thread: Joona I Palaste: "Re: Wierd output instead of 0s and 1s"
- Reply: Joona I Palaste: "Re: Wierd output instead of 0s and 1s"
- Reply:(deleted message) Mark L Pappin: "Re: Wierd output instead of 0s and 1s"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 1 Mar 2004 02:33:41 -0800
A practice excercise from K&R. Kindly read the comments within the
program. I'd be very grateful to people who helped. Why is it that I
get the wierd face-like characters on the screen instead of the
boolean output 0s or 1s?
#include <stdio.h>
/*This program is made to check that leaving the brackets around the
epxression (c=getchar()) in
the statement while ((c=getchar()) !=EOF) produces a boolean output in
C which would either be
0 (false) or 1 (true). This would happen because the relational
operator != has precedence over the assignment
operator =.
*/
void main()
{
int c;
while (c=getchar() != EOF) putchar(c);
/* Surprisingly, it doesn't produce zeros while I type; rather it
produces some wierd characters that look
half like zeros and half like smileys. And doing a Ctrl+Z, which I
thought was the substitute for EOF does
not produce a 1 (true value) */
}
- Next message: Joona I Palaste: "Re: Elementary questions from a beginner"
- Previous message: CBFalconer: "Re: In and Out on port space within C - any standard?"
- Next in thread: Joona I Palaste: "Re: Wierd output instead of 0s and 1s"
- Reply: Joona I Palaste: "Re: Wierd output instead of 0s and 1s"
- Reply:(deleted message) Mark L Pappin: "Re: Wierd output instead of 0s and 1s"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]