Thread: Storing function pointers in generic pointers

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jun 2008
    Posts
    54

    Storing function pointers in generic pointers

    Hi, I'm having trouble storing a function pointer in a generic pointer. Apparently I'm causing a screw up in the memory locations for one reason or another.

    The program causes a segmentation fault when I attempt to call the function via the new pointer, and when I checked it with a debugger, it was indeed not pointing to the correct place in memory. I'm not sure what I should do to fix the problem, though.

    Here is the program:
    http://pastebin.com/f3e1f4dde
    It's supposed to implement a really basic LIFO data stack.

    Here is what my output looks like:
    Code:
    ./cstackdemo
    Hello there.
    27
    Segmentation fault
    If you want to try to compile this piece of crap (bless your heart), I have a makefile for it that you can download here:
    http://github.com/pipingcats/cstack/tree/master
    Last edited by Boxknife; 08-01-2009 at 01:46 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. state machine using function pointers
    By meena_selvam in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 02:09 PM
  2. doubt in c parser coding
    By akshara.sinha in forum C Programming
    Replies: 4
    Last Post: 12-23-2007, 01:49 PM
  3. Game Pointer Trouble?
    By Drahcir in forum C Programming
    Replies: 8
    Last Post: 02-04-2006, 02:53 AM
  4. <Gulp>
    By kryptkat in forum Windows Programming
    Replies: 7
    Last Post: 01-14-2006, 01:03 PM
  5. Array of function pointers?
    By The V. in forum C++ Programming
    Replies: 3
    Last Post: 10-16-2001, 08:37 PM