Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

C++ Pointers Help

I'm working on a c++ programm since some days, all was going well, but now I have found some little trouble with pointers. I am working with SDL and I want is to convert a pointer to a struct(namely SDL_Surface) to an int(or other numeric type). And also convert the int to the pointer again.
Code:
SDL_Surface* pic = NULL;

pic = IMG_Load("test.png"); // Loads the image

int pointer;

pointer = {pic to int}; // Pointer to int, what {pic to int} should be?

SDL_Surface* pic2 = pointer; // Int to pointer
I still don't know if that's possible. If not, I will have to do things in an other much complicated way...
 
I have tried both "(int) pic" and "&pic", but never tried both things together, hehe. Thanks Zeriab! Now I can continue with my project :)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top