Strcpy on SysV vs. BSD.
Guy Harris
guy at auspex.auspex.com
Mon Sep 3 08:13:09 AEST 1990
>Heavens, you've made one of the most common blunders made by novice C
>programmers.
Or, to put it another way, "just because routine 'foobar()' is defined
as taking a 'char *' as an argument doesn't mean:
1) what you pass to it has to be a variable declared as a 'char *'
or
2) that you can just pass it any random variable declared as a 'char
*'."
I suspect the reason some novice C programmers make this blunder is that
they see something like
int stat(path, buf)
char *path;
struct stat *buf;
in the manual, and think "ok, I have to declare a 'struct stat *' to
pass to 'stat()'," and do something such as
struct stat *buf;
...
if (stat("my_file", buf) < 0)
...
More information about the Comp.unix.questions
mailing list