Path: utzoo!mnetor!tmsoft!torsqnt!hybrid!scifi!bywater!uunet!cbmvax!higgin From: higgin@cbmvax.commodore.com (Paul Higginbottom - CATS) Newsgroups: comp.sys.amiga.programmer Subject: Re: Help this neophyte... Keywords: manx 3.6a problems Message-ID: <19534@cbmvax.commodore.com> Date: 5 Mar 91 18:35:05 GMT References: <27282@uflorida.cis.ufl.EDU> Reply-To: higgin@cbmvax.commodore.com (Paul Higginbottom - CATS) Organization: Commodore, West Chester, PA Lines: 42 Summary: Expires: Sender: Followup-To: Distribution: In article <27282@uflorida.cis.ufl.EDU> barbecue@pine.circa.ufl.edu writes: $My first question is this: when I attempted to write a simple $program to do some string manipulations, I encountered a bug| $feature|pecadillo of my compiler with regard to the index(), $rindex(), strchr() and strrchr() functions. It seems that these $functions are returning integers, when the documentation says $they should return char pointers. I have looked in all my reference $materials, and tried C on other systems, and these functions work $as advertised. Why is Manx returning these integers? I even tried $using the integers in several ways, but had little luck. These are $the kinds of experiences that can really darken one's day when one $is a novice. I do not NEED these functions, but it would be nice $if they would work. Can anyone explain this and possibly offer a $solution? The answer to your problem is actually very simple. Those functions DO work as documented, but the compiler assumes all functions return ints by default, unless declared otherwise. Usually, you'd use the 'extern' keywork, e.g.: my_func() { extern char *index(); char *x; ... x = index(...); ... } Technically speaking you don't need the 'extern', by the way, but you must declare the function if it doesn't return an int and its source is not compiled above the function that needs it in the same pass of the compiler. $BARBECUE@pine.circa.ufl.edu - Internet $BARBECUE@UFPINE - BITNET $Barbecue@ribs.grill.patio.backyard - Foodnet Hope this helps, Paul.