Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > pointer to int

Reply
Thread Tools

pointer to int

 
 
Michael
Guest
Posts: n/a
 
      07-18-2010
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
 
Reply With Quote
 
 
 
 
Michael
Guest
Posts: n/a
 
      07-18-2010
PS: Exactly like so and TextureId is a int

lotto[TextureId] = IMG_Load(TextureFileName);
 
Reply With Quote
 
 
 
 
Alf P. Steinbach /Usenet
Guest
Posts: n/a
 
      07-18-2010
* 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

--
blog at <url: http://alfps.wordpress.com>
 
Reply With Quote
 
Michael
Guest
Posts: n/a
 
      07-18-2010
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
 
Reply With Quote
 
Michael
Guest
Posts: n/a
 
      07-19-2010
So now to avoid:
>> libpng error: Decompression error

which occurs at: IMG_Load
I could move SDL_Surface out of the texture load function?

int LoadGLTexture(char *pFileName, int TextureId, SDL_Surface* lotto[]);

This prototype is wrong. How should it be? See also here:
http://www.gamedev.net/community/for...opic_id=546917
Thanks
 
Reply With Quote
 
Michael
Guest
Posts: n/a
 
      07-19-2010
if u don't know get lost
 
Reply With Quote
 
Alf P. Steinbach /Usenet
Guest
Posts: n/a
 
      07-19-2010
* Michael, on 19.07.2010 14:28:
> if u don't know get lost


You're supplying to little information for anyone to help you.

Please read <url: http://www.parashift.com/c++-faq-lit...t.html#faq-5.8
>.


Then repost your questions following the guidlelines there.


Cheers & hth.,

- Alf

--
blog at <url: http://alfps.wordpress.com>
 
Reply With Quote
 
LR
Guest
Posts: n/a
 
      07-19-2010
Michael wrote:
> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
why is int a[0] not allowed, but int* a = new int[0] is? haijin.biz@gmail.com C++ 9 04-17-2007 09:01 AM
Difference between int i, j; and int i; int j; arun C Programming 8 07-31-2006 05:11 AM
int a[10]; int* p=(int*)((&a)+1); But why p isn't equal to ((&a)+1)? aling C++ 8 10-20-2005 02:42 PM
int main(int argc, char *argv[] ) vs int main(int argc, char **argv ) Hal Styli C Programming 14 01-20-2004 10:00 PM
dirty stuff: f(int,int) cast to f(struct{int,int}) Schnoffos C Programming 2 06-27-2003 03:13 AM



Advertisments