Thread: Question about Pointer syntax in function declarations?

  1. #1
    Registered User
    Join Date
    Jul 2012
    Syracuse, New York, United States

    Question about Pointer syntax in function declarations?

    So I'm reading through "Jumping into C++" and I've made way through to chapter 15: "intro to data structures w/ linked lists". This has been the most difficult for me to wrap my head around so far. It's sort of making sense to me on a theoretical level but there is a bit of syntax that confuses me. Why do I need to use "*" when declaring a function, or rather what effect does this have?

    //exp function deceleration
    type* funcName ();
    //type = a structure if that's relevant

    The only information I've been able to gather via google involves pointers to function but that is a different topic and a different syntax...

    This is probably going to sound silly to most of you more experienced programmers but I'm still learning and I'm finding it difficult to find information about this particular syntax.

  2. #2
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    No, this isn't a function pointer.
    This is a function that returns a pointer.

    (If you write one, remember not to return a local address.)

  3. #3
    Join Date
    Oct 2007
    Inside my computer
    It's a function whose return type is type*.
    int* foo();
    A function named foo that returns an int* (pointer to an int).
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  4. #4
    Registered User
    Join Date
    Jul 2012
    Syracuse, New York, United States
    Thanks manasij7479 and Elysia, I had suspected that was what was going on but I couldn't find any hard evidence to confirm it, very helpful, makes perfect sense.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 5
    Last Post: 01-04-2012, 01:25 AM
  2. Problem with a function pointer syntax
    By manasij7479 in forum C++ Programming
    Replies: 15
    Last Post: 07-04-2011, 11:08 AM
  3. Replies: 2
    Last Post: 12-01-2010, 01:05 PM
  4. Function syntax to return a pointer...
    By tzuch in forum C Programming
    Replies: 1
    Last Post: 05-29-2008, 07:53 AM
  5. struct pointer to function syntax
    By kermit in forum C Programming
    Replies: 2
    Last Post: 03-21-2004, 04:01 PM