Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!seismo!mimsy!chris From: chris@mimsy.UUCP Newsgroups: comp.lang.c Subject: Re: Help needed with and strings. Message-ID: <5997@mimsy.UUCP> Date: Fri, 27-Mar-87 15:08:09 EST Article-I.D.: mimsy.5997 Posted: Fri Mar 27 15:08:09 1987 Date-Received: Sat, 28-Mar-87 16:22:21 EST References: <5902@brl-adm.ARPA> Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742 Lines: 29 In article <5902@brl-adm.ARPA> V053MDHL%UBVMS.BITNET@wiscvm.wisc.edu writes: >[1] The function returns a pointer to the first character in > the string. It was my belief that the pointer should point to the > last <\0> character .... fgets returns either its first argument or NULL. Where did you acquire this belief? >[2] In scanning the string for characters, I can compare with neither > "\n" or "\0", as neither of these characters, while actually pre- > sent in the strings, registers when compared. From the way you phrased this, I suspect you have a test that looks like this: if (c == "\n" || c == "\0") If `c' is a character or integer value, this should elicit a warning from the compiler, since "\n" and "\0" become pointer values. Change the test to if (c == '\n' || c == '\0') 'x' produces an integer constant; "string" produces a pointer to an unnamed aggregate constant, type array N of char, where N is strlen(string)+1. -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7690) UUCP: seismo!mimsy!chris ARPA/CSNet: chris@mimsy.umd.edu