November 19, 2001
hello

i was just wondering something. in C you hit a dead end when you
trying to get a size of arg that passed as pointer to a function.

for example:
	char *strcpy(char *dest, const char *src)

if you trying to pass a static buffer as one of these args
you can't get their size within the function.
most likely you will get sizeof() return as 4.

i am wondering if there is a way that you can guys try make this
process (getting size of pointers (dyanmic) or static within function)

p.s
	for y`all C folks, the only way i figure how to get it
	is to starting walking trough the entire stack.


izik @ http://www.tty64.org

November 19, 2001
"Izik" <izik@tty64.org> wrote in message news:3BF9682A.7090901@tty64.org...

> i was just wondering something. in C you hit a dead end when you trying to get a size of arg that passed as pointer to a function.
>
> for example:
> char *strcpy(char *dest, const char *src)
>
> if you trying to pass a static buffer as one of these args
> you can't get their size within the function.
> most likely you will get sizeof() return as 4.

In C, you'd probably want to use strlen(). =)

In D, use dynamic arrays:

    char[] strcpy(out char[] dest, in char[] src)
    {
        for (int i = 0; i < src.length; i++)
        {
            ...
        }
    }

Dynamic array in D is much like a pointer which knows
size of memory block it points to.