Function syntax to return a pointer...

This is a discussion on Function syntax to return a pointer... within the C Programming forums, part of the General Programming Boards category; Hey all. I'm about halfway through a book called "Teach Yourself C in 21 Days." Great book, but I can't ...

  1. #1
    Registered User
    Join Date
    Mar 2008
    Posts
    6

    Function syntax to return a pointer...

    Hey all. I'm about halfway through a book called "Teach Yourself C in 21 Days." Great book, but I can't find out how to return a pointer from a function. Can anyone give me the syntax, or an example of the declaration?

    Would be most appreciated.

    tzuch

  2. #2
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,548
    Returning something is nothing special. But maybe you're looking for something else?
    Code:
    char* foo()
    {
        return malloc(5);
    }
    
    int main()
    {
        char* p = foo();
        free(p);
    }
    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.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. An error is driving me nuts!
    By ulillillia in forum C Programming
    Replies: 5
    Last Post: 04-04-2009, 09:15 PM
  2. In over my head
    By Shelnutt2 in forum C Programming
    Replies: 1
    Last Post: 07-08-2008, 06:54 PM
  3. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  4. Another weird error
    By rwmarsh in forum Game Programming
    Replies: 4
    Last Post: 09-24-2006, 10:00 PM
  5. Direct3D problem
    By cboard_member in forum Game Programming
    Replies: 10
    Last Post: 04-09-2006, 03:36 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21