Using small memory model functios on huge arrays
Martin Schulte
schulte at thp.uni-koeln.de
Wed May 30 21:33:52 AEST 1990
Path: uni-koeln!unido!mcsun!uunet!attcan!telly!druid!darcy
From: darcy at druid.uucp (D'Arcy J.M. Cain)
Newsgroups: comp.lang.c
Subject: Re: Using small memory model functions on huge arrays (was See below...)
In <1990May28.190935.22913 at druid.uucp> D'Arcy J.M. Cain writes:
> [deleted]
>
>char *strcpy(dest, src)
> char *dest, *src;
> {
> char *s = src;
>
> while (*d++ = *s++) ;
> return src;
> }
>
>Which doesn't work because it ignores the fact that the arguments may be
>different sized pointers. ...
I don't quite understand what you mean there, could you explain it a bit more !
Another annotation to your next macro:
>#define mixstrcpy(d, s) { int k = 0; do d[k] = s[k]; while (s[k++]);}
I will warn you about one danger which comes along when using macros like
the above: If you do
char l[6],*k="hallo";
.
.
mixstrcpy(l,k);
your program will become syntactically incorrect. I remember that one day,
I had a similar problem, but there was no compiler error, the program just
didnot what I intended it to do. It was a hard job of debugging it.
So, be warned about constructs like the above, in any case use "unique"
names for your "macro"-variables (e.g mixstr_k), not common ones like i,k,...
Martin Schulte
--
----------------------------------
Martin Schulte
Institute for Theoretical Physics
University of Cologne/Germany
Internet: schulte at thp.uni-koeln.de
More information about the Comp.lang.c
mailing list