Coder's Guild Mailing List

RE: C question...

Posted by John Meyer on 2000-03-09

Isn't a pointer _to_ a function that, say, returns and int and takes a char
something like this:

(int *)(char *)

-----Original Message-----
From: tcg@xxxx.xx.xx [mailto:tcg@xxxx.xx.xx]On Behalf Of Morgan Terry
Sent: Thursday, March 09, 2000 12:54 PM
To: john_meyer@xxxxxxxxx.xxx
Subject: Re: C question...


Kwisatz Haderach wrote:
>
> How would I go about passing a pointer to a function
> by reference? For example:
>
> int do_something(char *ptr)
> {
>     ptr += 5;
>     return something;
> }
>
> int main()
> {
>     char *ptr;
>     char line[] = "Hello World";
>     ptr = line;
>     do_something(ptr);
>
> //ptr still points to the base address of line!!
>
>     return 0;
> }
>
> I tried using a double pointer (or whatever they're
> called - I can't find a book that covers it)
>
> int do_something(char **ptr)
> {
>     ...
> }
>
> but that doesn't work either. Then again, I'm probably
> doing something wrong. Can anyone help?
>
> Thanks,
> Sharvil Nanavati
> __________________________________________________
> Do You Yahoo!?
> Talk to your friends online with Yahoo! Messenger.
> http://im.yahoo.com
> > To signoff send a mail to listserver@xxxx.xx.xx with
>   "signoff tcg" in the body of your message.

I've been doing some stuff with linked lists, and in my class we've been
using something like:

	int do_something(char *&a_pointer)
	{
		...
	}

Hope this helps you out...
--
Morgan	[morgan@xxxxxxxxxxx.xxx]

He who sacrifices functionality for ease of use loses both and deserves
neither.
To signoff send a mail to listserver@xxxx.xx.xx with
  "signoff tcg" in the body of your message.

To signoff send a mail to listserver@xxxx.xx.xx with 
  "signoff tcg" in the body of your message.