note that the arrays do not carry over to each variable only to the one specified which was the first hence why:
which would work as it has no arrays
Those are not arrays. They are pointers. Pointers and arrays are different but arrays can be degraded to a pointer datatype.
Code:
int array[5];
cout << sizeof(array) << endl
int * pArray = new int[5];
cout << sizeof(pArray) << endl;
delete [] pArray;
pArray = NULL;
Take a look at the output, that is the main distinction.
02-14-2008, 09:58 AM
Auraomega
I'm getting a truely evil error at the moment, no idea what so ever as to what the cause is:
Error:
source/main.c:16: error: two or more data types in declaration specifiers
source/main.c:16: error: expected identifier or '(' before 'asm'
Line 16:
PSP_MODULE_INFO("Rise of Darkness", 0x800, 0, 1);
Everything looks fine to me, so what is causing the error?
-Aura
02-14-2008, 10:39 AM
itdemo
Hi guy's.
I am having one more problem with my program and it is:
I am using strcat() so that when they press X it adds for example 1 to the end of the variable. Then later on i am casting it to a double from a character. But i get this error:
main.c: 394: error: pointer value used were a floating point value was expected.
Line 394: float alldouble = (float)allchar;
Thanks,
Gavin/ITDemo
02-14-2008, 11:45 AM
Archaemic
Zitat:
Zitat von Auraomega
I'm getting a truely evil error at the moment, no idea what so ever as to what the cause is:
Error:
source/main.c:16: error: two or more data types in declaration specifiers
source/main.c:16: error: expected identifier or '(' before 'asm'
Line 16:
PSP_MODULE_INFO("Rise of Darkness", 0x800, 0, 1);
Everything looks fine to me, so what is causing the error?
-Aura
Line 15 is causing the problem, most likely.
02-14-2008, 12:01 PM
Mr305
Zitat:
Zitat von yaustar
Those are not arrays. They are pointers. Pointers and arrays are different but arrays can be degraded to a pointer datatype.
I knew he meant pointers when he said arrays. :D
02-14-2008, 12:07 PM
yaustar
Zitat:
Zitat von itdemo
Hi guy's.
I am having one more problem with my program and it is:
I am using strcat() so that when they press X it adds for example 1 to the end of the variable. Then later on i am casting it to a double from a character. But i get this error:
main.c: 394: error: pointer value used were a floating point value was expected.
Line 394: float alldouble = (float)allchar;
Thanks,
Gavin/ITDemo
Assuming allchar is either a char * or char [], you can't cast to a float like that. Read my reply on the functions you should be using a few pages back.
-= Double Post =-
Zitat:
Zitat von yaustar
If you are going to implement the OSK the way I think you are going to, you are going to hit the same problem as before.
Zitat:
Zitat von yaustar
It comes out as a C string which is a char *. You have to convert it to a float using stringstreams (C++) or sscanf (C).
02-14-2008, 12:10 PM
Auraomega
Zitat:
Zitat von Archaemic
Line 15 is causing the problem, most likely.
Thats what I thought, but its blank above, not taking into consideration the header files, and thats it. As I said, its really weird.
-Aura
02-14-2008, 12:53 PM
slicer4ever
i'll make sure that i don't make that mistake in the future yaustar and thanks for clarifing this up for me=-)
02-14-2008, 01:47 PM
Judas
Zitat:
Zitat von Auraomega
Thats what I thought, but its blank above, not taking into consideration the header files, and thats it. As I said, its really weird.
-Aura
The header file could have an error in it. Any headers that you made? Check those.
-= Double Post =-
Zitat:
Zitat von itdemo
Hi guy's.
I am having one more problem with my program and it is:
I am using strcat() so that when they press X it adds for example 1 to the end of the variable. Then later on i am casting it to a double from a character. But i get this error:
main.c: 394: error: pointer value used were a floating point value was expected.
Line 394: float alldouble = (float)allchar;
Thanks,
Gavin/ITDemo
All this stuff is just plain C, it's NOT PSP specific. So search Google, for "char to float in c". Also, did you say your uncle knows how to program? If so, this is pretty basic stuff.
02-14-2008, 03:08 PM
Auraomega
Zitat:
Zitat von Judas
The header file could have an error in it. Any headers that you made? Check those.
You got it, I decided to start commenting out my headers, and it turns out I forgot to add the ; on the end of each of my enums, which caused obvious problems :p
Thanks for that (but now I'll never live that down after I said there was no way that would be it to a friend :ROFL: )
-Aura
02-14-2008, 10:39 PM
spike021
Alright, I keep running into this problem, I know it's not too complicated but here goes:
I am adding more to sg57's game, blah blah blah, and one of the new "things' is that after 100 kills another "weapon" is added, well, I have made a .png for the new weapon, and I have added that to the OSL_IMAGE area. Maybe because I am not familiar with his style of coding, I can't figure out where the part of the code is that he has his drawing code for the first weapon. It looks like this for the springphysics and also the springobject(how the object moves and etc):
and then there is the rdrawline area that looks like this:
And since this is probably an easy question, I feel nooby, but I don't really care, as I will be learning something newer. :p
Reply if you need to see more of the code, thanks.
02-14-2008, 11:56 PM
Xsjado7
Hey guys,
iv never really messed with pointers but i was reading about them last night and i dont think im quite understanding them.
First of all, how does
Code:
int *my_int;
differ from
Code:
int my_int;
?
Also, i dont see how they differ from normal ints. If you do
Code:
int my_int;
int *my_int2;
my_int = *my_int2;
its the same as
Code:
int my_int, my_int2;
my_int = my_int2;
isnt it?
02-15-2008, 03:43 AM
yaustar
Code:
int *my_int;
Allocates memory on the stack to store a memory address that 'points' to an int.
Code:
int my_int;
Allocates memory on the stack to store an int datatype.
Code:
int anInt = 0;
int * pInt = &anInt;
pInt now contains the value of the memory address of anInt.
Code:
*pInt = 5;
Dereferences pInt so now we are accessing what pInt was pointing to. anInt is now 5.
Code:
pInt = new int;
Allocated memory on the heap for an int datatype and the address is now stored in pInt.
Code:
*pInt = 6;
The int on the heap that the pInt is pointing to is now 6. anInt remains at 5 because pInt is no longer is storing the address of pInt.
int main()
{
int anInt = 5;
AddMe( &anInt );
//anInt is now 6
return 0;
}
02-15-2008, 05:00 AM
Xsjado7
Thanks for clearing that up Yaustar. I got a better understanding of them now, thanks again :D
02-15-2008, 05:25 AM
yaustar
Zitat:
Zitat von Xsjado7
Thanks for clearing that up Yaustar. I got a better understanding of them now, thanks again :D
Wait until you get to pointers to pointers to pointers :P.
Code:
int *** pppInt = NULL;
02-15-2008, 06:04 AM
Xsjado7
:eek: ...cant wait...
02-15-2008, 11:59 AM
SG57
Zitat:
Zitat von spike021
Alright, I keep running into this problem, I know it's not too complicated but here goes:
I am adding more to sg57's game, blah blah blah, and one of the new "things' is that after 100 kills another "weapon" is added, well, I have made a .png for the new weapon, and I have added that to the OSL_IMAGE area. Maybe because I am not familiar with his style of coding, I can't figure out where the part of the code is that he has his drawing code for the first weapon. It looks like this for the springphysics and also the springobject(how the object moves and etc):
and then there is the rdrawline area that looks like this:
And since this is probably an easy question, I feel nooby, but I don't really care, as I will be learning something newer. :p
Reply if you need to see more of the code, thanks.
It's not my style of coding, rather how OSlib does it's drawing. Check in the main function for oslStartDrawing()function being called. I try to do ALL my drawing-only code there, no thinking or input at all as the time it takes oslStartDrawing and oslEndDrawing to be called is where you'll earn your FPS (using OSlib). So calling it multiple times in a function or anywhere else will start to bog the FPS down. That physics function and drawline function are just to make it more readable within the main loop. (also, what happened to the formatting?)
P.S. sorry if you answered this yourself already, i went to the last thread and read what I missed while I was away ;)
02-15-2008, 12:35 PM
spike021
Zitat:
Zitat von SG57
It's not my style of coding, rather how OSlib does it's drawing. Check in the main function for oslStartDrawing()function being called. I try to do ALL my drawing-only code there, no thinking or input at all as the time it takes oslStartDrawing and oslEndDrawing to be called is where you'll earn your FPS (using OSlib). So calling it multiple times in a function or anywhere else will start to bog the FPS down. That physics function and drawline function are just to make it more readable within the main loop. (also, what happened to the formatting?)
P.S. sorry if you answered this yourself already, i went to the last thread and read what I missed while I was away ;)
Basically, I am just going to use OSlib to do the drawing, but I thought that I may just try within the code itself, but I see that won't work too well, so when I am back from school, I will get down to it.
And then I will just do what you said and check back in the function for what I am looking for, and it almost is working so hopefully not too much longer.
02-15-2008, 02:26 PM
Auraomega
Is there a way I can use an if statement in the way shown below (the code of course doesn't work, but it gives the idea better than I can explain)
as my code uses 9 of these, so my code is going to get messy if I do the above.
Thanks.
-Aura
02-15-2008, 02:47 PM
Archaemic
Code:
switch(somestring[someplace]) {
case '#': stuff; break;
case '/': stuff; break;
...
default: otherstuff; break;
}
Switch statements are your friend!
If you want to just have it be one thing for all cases, then just do this:
Code:
switch(somestring[someplace]) {
case '#': case '/':
stuff;
break;
...
default: otherstuff; break;
}
02-15-2008, 02:51 PM
SG57
No, you may be thinking of something like -
Code:
if(somestring[someplace] == ('#' || '/')) break;
But that doesn't work either. I believe it's saying
"if somestring[someplace]'s ASCII char value is true to ((if the value of the ASCII char '#' is true to 1 return true else false) OR (if the value of the ASCII char '/' is true to 1 return true else false))"
02-15-2008, 03:15 PM
Auraomega
Thanks Archaemic, I use switches a lot, but I've never come across the 2nd method which would probably suit my case a lot better.
@SG57
I basically want to check if a variable is equal to something, or to something else, 9 times over, all giving the same outcome (hence why I didn't use switches first), and in the shortest possible code to make life easier.
-Aura
-= Double Post =-
Ah, that didn't work, now I remember the other reason I didn't use switches... any breaks insides of switches count as a break from the switch, and not from an exterier while loop. So its back to the drawing board, unless there is another feature I am missing? (I never did work out what the continue was for).
This is slowing me down so much, but if someone could test out the physics game for me because I fixed it and it should definitely work now.
All that is needed is for it to be compiled, and then to play it to 100 kills. That is when a new ball should pop out and you should be able to use it.
If anyone is interested, PM for the download. Or reply back here.
02-15-2008, 04:23 PM
Auraomega
Zitat:
Zitat von SG57
Not sure what you mean there Aura.
Ignore me, I think I'm in dumb mode today... I forgot to place the stuff into the default case which is why the problems occured. I think I'll go sleep now and hopefully be in a more intelligent mood :p
-Aura
02-15-2008, 05:03 PM
SG57
I still love you Aura ;)
02-16-2008, 07:48 AM
yaustar
Zitat:
Zitat von Auraomega
Is there a way I can use an if statement in the way shown below (the code of course doesn't work, but it gives the idea better than I can explain)
Hi, i have been recently endeavoring into the whole PRX part of PSP and was wondering of which kernel command's i would have to use to be able to make a messagebox appear in the XMB :).