From owner-freebsd-questions@FreeBSD.ORG Tue Mar 1 05:23:28 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 248AE16A930 for ; Tue, 1 Mar 2005 05:23:28 +0000 (GMT) Received: from web51610.mail.yahoo.com (web51610.mail.yahoo.com [206.190.38.215]) by mx1.FreeBSD.org (Postfix) with SMTP id 6B81143D5E for ; Tue, 1 Mar 2005 05:23:27 +0000 (GMT) (envelope-from jay2xra@yahoo.com) Received: (qmail 29839 invoked by uid 60001); 1 Mar 2005 05:23:23 -0000 Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; b=ebVPfBK+rKNZYi/LFVqdZuzLVGFAPDiR52ySv4uYXkD5B1mNE8vUBbnMqTNWX1gXTg641nGCprytkKV7M6H1a4lbzv5XLTo1a16MtXykj6D7ANJd8RAIwQAgpDD9t1//AAMjTGQPHxGhePB63z4AzJheFEAYfV6M0qKW0N5w+RQ= ; Message-ID: <20050301052323.29837.qmail@web51610.mail.yahoo.com> Received: from [202.90.128.21] by web51610.mail.yahoo.com via HTTP; Mon, 28 Feb 2005 21:23:22 PST Date: Mon, 28 Feb 2005 21:23:22 -0800 (PST) From: Mark Jayson Alvarez To: freebsd-questions@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Word counting by Kernighan won't compile =( X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Mar 2005 05:23:28 -0000 Hi, Sorry for asking this question here. I just thought that this might be a platform specific issue=). I'm reading this book(The C Programming Language 2nd Edition by Brian W. Kernighan. Upon reading the book, I came up with this example code. It says, it will count the number of words, lines and characters in the command line, until I send an EOF signal. I copied it verbatim and tried compiling it with plain "cc myprog.c" It exited with errors: word.c: In function `main': word.c:17: error: invalid lvalue in assignment Any idea what this means? Thanks. Here's the code: #include #define IN 1 #define OUT 0 main() { int c, nl, nw, nc, state; state = OUT; nl = nw = nc = 0; while ((c = getchar()) != EOF) { ++nc; if (c == '\n') ++nl; if (c == ' ' || c == '\n' || c = '\t') state = OUT; else if (state == OUT) { state = IN; ++nw; } } printf("%d %d %d\n", nl, nw, nc); } __________________________________ Do you Yahoo!? Yahoo! Mail - 250MB free storage. Do more. Manage less. http://info.mail.yahoo.com/mail_250