From: Martin Ambuhl Newsgroups: comp.os.msdos.djgpp Subject: Re: parsing function not working Date: Wed, 02 Dec 1998 01:32:47 -0500 Content-Transfer-Encoding: 7bit References: <01be1db7$840e4160$5640ab95 AT JUry DOT law DOT unsw DOT edu DOT au> X-Posted-Path-Was: not-for-mail X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-ELN-Date: 2 Dec 1998 06:33:35 GMT X-ELN-Insert-Date: Tue Dec 1 22:35:08 1998 Organization: Nocturnal Aviation Lines: 48 Mime-Version: 1.0 NNTP-Posting-Host: 1cust196.tnt11.nyc3.da.uu.net Message-ID: <3664DF0F.3D480EA2@earthlink.net> X-Mailer: Mozilla 4.5 [en] (Win95; I) To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Joe Ury wrote: > > This test (below) works OK, but when I #include the function into a larger > file I > get an "assignmet makes pointer from interger without a cast (refering to > line five of cts.inc)" msg and I am passing type char * to it just as in > the test below. ============= If you use the compilation option -ansi, then strsep will have no prototype in scope since it is not a standard C function. So don't use the -ansi option, or learn how to write your code using the standard function strtok instead. And it is a violation of the standard to use printf, a variadic function, without a prototype in scope, so #include ============ > > #include > #include "c:\djgpp\cts.inc" > char *pc = "P005.133/C/25K"; > int main() > { > float dog; > dog = CallToSort(pc); > printf("dog = %f\n",dog); > } > > below is the function "cts.inc": > > float CallToSort(char *buf) > { int i = 0; > char *tok; > char **bp = &buf; > double flo = 0, data[4]; > while (tok = strsep(bp, "ABCDEFGHIJKLMNOPQRSTUVWXYZ/")){ > flo = atof(tok); > if (flo > 0){ > data[i] = flo; > ++i; > } > } > return data[0]; > } -- Martin Ambuhl (mambuhl AT earthlink DOT net) Note: mambuhl AT tiac DOT net will soon be inactive