[sclug] Off topic C question
Dickon Hood
sclug at splurge.fluff.org
Fri Sep 22 10:17:20 UTC 2006
On Fri, Sep 22, 2006 at 11:11:32 +0100, Patrick wrote:
: Hi all,
: Can anyone see why this character counting program always finds zero
: characters? Its based on an example from K&R Chapter 1 which also fails.
: #include "stdio.h"
: int main()
: {
: /* count characters*/
: FILE *inFile;
: inFile = fopen("motd.xml", "r");
: int c = 0;
: long lc = 0;
: while ((c = getc(inFile)) != EOF)
: {
: if (c == "l") {
^^^ that's a char *, not a char. You want
single quotes and a cast.
: ++lc;
: }
: }
: printf("Typed %1d lines\n", nc);
: system("pause");
: return 0;
: }
--
Dickon Hood
Due to digital rights management, my .sig is temporarily unavailable.
Normal service will be resumed as soon as possible. We apologise for the
inconvenience in the meantime.
No virus was found in this outgoing message as I didn't bother looking.
More information about the Sclug
mailing list