pointer to int

M

Michael

Hi
If I do:
SDL_Surface* vector[9];
vector[0] = IMG_load(...);
vector[1] = ...
I get:
invalid conversion from ‘SDL_Surface*’ to ‘int’
Any ideas on how to do such? Many thanks
Michael
 
M

Michael

PS: Exactly like so and TextureId is a int

lotto[TextureId] = IMG_Load(TextureFileName);
 
A

Alf P. Steinbach /Usenet

* Michael, on 18.07.2010 13:27:
Hi
If I do:
SDL_Surface* vector[9];
vector[0] = IMG_load(...);
vector[1] = ...
I get:
invalid conversion from ‘SDL_Surface*’ to ‘int’
Any ideas on how to do such? Many thanks

Under reasonable assumptions the code you've shown should work.

Post a more complete example, like, actual code, and actual error message and
error location.


Cheers & hth.,

- Alf
 
M

Michael

Well I try to get around this error:
libpng error: Decompression error
which i get at runtime. So i want to move this out of the texture load
function into a init function:

SDL_Surface* lotto[TextureId]

than later the texture load function:

lotto[TextureId] = IMG_Load(TextureFileName)


but now I get at compile:
‘lotto’ was not declared in this scope. How should i declare lotto?
Many thanks
Michael
 
L

LR

Michael said:
Well I try to get around this error:
libpng error: Decompression error
which i get at runtime.

Can you say what compiler, linker and debugger you are using?

So i want to move this out of the texture load
function into a init function:

SDL_Surface* lotto[TextureId]

than later the texture load function:

lotto[TextureId] = IMG_Load(TextureFileName)


but now I get at compile:
‘lotto’ was not declared in this scope.

It sounds to me like you want to do something like this:

void someFunction() {
int someVariable;
}

void someOtherFunction() {
someVariable = 5; // someVariable isn't in scope here
}

"lotto" must be declared in the scope in which you intend to use it.
You can consider making it global, but that's probably not a good idea.
You may also consider passing a pointer or reference to "lotto" to the
function you want to use it in.

Was lotto a data member of a class? Are the functions you mentioned
member functions? That would be different.

class SomeClass {
int someVariable;
public:
void someFunction() {
someVariable = -92;
}
};



I'm sorry, but I can't tell what your problem is from the description
you've given. Can you please be more specific?
How should i declare lotto?

I think it's more a question of where, but I'm not really sure. Again,
if you'll please be more specific about the problem you are having, I'm
sure someone will try to give you a more useful answer.


Also please consider,
const int n = 5;
int a[n];
a[n] = 1;
May compile but will not work. In this little code snippet "a" is an
array of five ints and has valid indicies [0,4].

Many thanks

HTH.

LR
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top