Arguments in function

This is a discussion on Arguments in function within the C Programming forums, part of the General Programming Boards category; Heres some objects I have setup in SDL: Code: SDL_Surface* screen; SDL_Surface* tiles; SDL_Rect src, dest; Heres an example of ...

  1. #1
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218

    Arguments in function

    Heres some objects I have setup in SDL:
    Code:
    SDL_Surface* screen;
    SDL_Surface* tiles;
    SDL_Rect src, dest;
    Heres an example of passing these into a function:
    Code:
    SDL_BlitSurface(tiles , &src , screen , &dest);
    I want to write a function that accepts these arguments, but I'm not sure how to write it.
    As you can see I don't know what to put for the parameters 'src' and 'dest':
    Code:
    DoSomething(SDL_Surface *tiles, src, SDL_Surface *screen, dest)
    Could someone quickly tell me how I should do this? Thanks.

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,164
    Looks like SDL_Rect *src and SDL_Rect *dest to me...
    If you understand what you're doing, you're not learning anything.

  3. #3
    Dr Dipshi++ mike_g's Avatar
    Join Date
    Oct 2006
    Location
    On me hyperplane
    Posts
    1,218
    Yeah, thats what I tried at first but it would not work at the time. I just realized that I declared these:
    Code:
    SDL_Surface* screen;
    SDL_Surface* tiles;
    SDL_Rect src, dest;
    As globals, so I don't even have to pass them in. Maybe that was what caused the problem in the first place. I don't know.

  4. #4
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,555
    If they're declared as pointers, then you would need &dst and &src
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 02:07 AM
  2. Seg Fault in Compare Function
    By tytelizgal in forum C Programming
    Replies: 1
    Last Post: 10-25-2008, 03:06 PM
  3. Help passing arguments to function
    By HAssan in forum C Programming
    Replies: 2
    Last Post: 11-26-2007, 01:15 PM
  4. Arrays as function arguments :(
    By strokebow in forum C Programming
    Replies: 10
    Last Post: 11-18-2006, 02:26 PM
  5. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 06:18 AM

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