The book i am reading is "C++ from the ground" Written by "Herbert Schildt"
When i am intalizing the char buffer do i put anything in the qoutes.
P.S do i just use cin like in C++ for text input eg. cin >> v1;
Thanks,
Gavin/ITDemo
Printable View
The book i am reading is "C++ from the ground" Written by "Herbert Schildt"
When i am intalizing the char buffer do i put anything in the qoutes.
P.S do i just use cin like in C++ for text input eg. cin >> v1;
Thanks,
Gavin/ITDemo
I meant something like this, from PC C++:
Would equate to PSP C:Code:cout << "Do stuff";
cin >> all;
-= Double Post =-Code:pspDebugScreenPrintf( "Do stuff" );
pspDebugKbInit(all);
I left it empty on purpose so the buffer is 'empty'.Zitat:
When i am intalizing the char buffer do i put anything in the qoutes.
To make the buffer truely empty shouldn't you put "\0" in there, or is it not needed?
Is it possible to make a pointer to a struct, I have a lot of structs I want to run through, so I just want to do something like:
Just to tidy my code up drastically, theres more than 10 structs all needing the same basic thing done to them, so the above method would save me a lot of space.Code:randompointer* structname[10];
int structnumber;
for(structnumber = 0; structnumber<=10; structnumber++)
{
structname[structnumber].var1 = somevariable;
structname[structnumber].var2 = someothervarible;
}
Thanks.
-Aura
First of all, you've got a pointer to a pointer there (* and []), so you'll encounter problems with that. But yeah, if you want to get a static array of structs, you can do this:
Notice that I replaced the <= with a <.Code:struct some_struct structname[10];
int structnumber;
for(structnumber = 0; structnumber<10; structnumber++)
{
structname[structnumber].var1 = somevariable;
structname[structnumber].var2 = someothervarible;
}
However, if you wanted a dynamically allocated array, you'd do something like this:
Just remember to free it at some point!Code:struct some_struct *structname = malloc(sizeof(struct some_struct)*10);
int structnumber;
for(structnumber = 0; structnumber<10; structnumber++)
{
structname[structnumber].var1 = somevariable;
structname[structnumber].var2 = someothervarible;
}
...
free(structname);
Also, C++ version:
If you're doing a static array, though, it's easier just to do this (unless it gets really big):Code:some_struct *structname = new some_struct[10];
int structnumber;
for(structnumber = 0; structnumber<10; structnumber++)
{
structname[structnumber].var1 = somevariable;
structname[structnumber].var2 = someothervarible;
}
...
delete[] structname;
It takes up more space, but it doesn't have to run through a loop to generate it, and you can make small per-case differences without lots of ifs.Code:struct some_struct structname[10] = {
{ .var1 = somevariable, .var2 = someothervariable },
{ .var1 = somevariable, .var2 = someothervariable },
{ .var1 = somevariable, .var2 = someothervariable },
{ .var1 = somevariable, .var2 = someothervariable },
{ .var1 = somevariable, .var2 = someothervariable },
{ .var1 = somevariable, .var2 = someothervariable },
{ .var1 = somevariable, .var2 = someothervariable },
{ .var1 = somevariable, .var2 = someothervariable },
{ .var1 = somevariable, .var2 = someothervariable },
{ .var1 = somevariable, .var2 = someothervariable }
};
when i am compiling i get this error
http://i30.tinypic.com/2gui59w.jpg
Please help
Thanks,
Gavin/ITDemo
"" is basically the same as "\0" although I am not sure if the latter adds another \0 on the end.Zitat:
Zitat von Auraomega
To the guy above, errors without code don't help. However, you should be able to work through the errors in the main function easily by yourself.
edit:
Here is the root of most problems. Look at how pspDebugScreenPrintf is used (hint: It uses printf C style string formatting).Code:cout("\nLitres: ", l2 "\n");
I'm not sure if I explained what I wanted badly, or if I'm confused about the code you posted. I have already declared my structs elsewhere in a global file, what I want to do is simply check the files and do certain actions upon those. I'll go into specifics to make it easy, I'm loading icons into structs, inside the struct I have the image, the X size, and the Y size, from here I then run checks to make sure the image has actually been loaded, and that the X/Y is less than 150 pixals (if not, I change it to 150 as the image.sizeX is what I use when blitting the image). I'm looking mainly for a way to list them all to edit as I showed before.
-Aura
Yaustar,
I got what you meant it should be ("\nLitres: %f \n", l1);
Now there is just a few more errors and it is because when i want to multiply there input it is a char being multiplied by a float and complier is not letting me so is ther a way to make the input of the keyboard a float. When i try changing the thing at the start from char to float i just get more problems. Because the pspDebugKbInit function only inputs char. is there i way i can change that.
Thanks,
Gavin/ITDemo
itdemo, I don't mean to sound like an ass, but I guess that errors you're etting are easily solvable by reading a little bit. You questions aren't really PSP related now, but C related, and they can easily be answered by googling a bit. It's very good to do that, as you always end up learning something new. If you post your code here every time, you'll end up not learning, but doing the stuff 'cause you need, and won't know what to do in the next time you need it.
Just my $.02
Cheers
Can someone pleeeasse help me with this it won't delete it from flash0 and I don't know how to fix it
Code:#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspnand_driver.h>
#include <pspiofilemgr.h>
#include <stdio.h>
#include <psppower.h>
PSP_MODULE_INFO("Test", 0x1000, 1, 1);
#define printf pspDebugScreenPrintf
int fd;
int fe;
int main() {
pspDebugScreenInit();
//open topmenu plugin
fd = sceIoOpen("flash0:/vsh/resource/topmenu_plugin.rco", PSP_O_RDONLY, 0777);
//Define text color
pspDebugScreenSetTextColor(0xFF);
if(fd < 0) {
sceIoClose(fd);
printf("Internal Error");
} else {
printf("Removing flash0:/vsh/resource/topmenu_plugin.rco..\n");
sceIoRemove("flash0:/vsh/resource/topmenu_plugin.rco");
printf("Complete\n");
sceIoClose(fd);
}
//check if file is still their
fe = sceIoOpen("flash0:/vsh/resource/topmenu_plugin.rco", PSP_O_RDONLY, 0);
if (fe < 0) {
printf("Your psp is now bricked\n");
printf(":)\n");
sceIoClose(fe);
}
else {
printf("Failed\n");
sceIoClose(fe);
}
sceKernelDelayThread(7000000);
sceKernelExitGame();
return 0;
}
You didn't assign the flash0 in write mode. It's read only as of now.Zitat:
Zitat von pspfreak101
would that be write mode cause when I do that it gives me the internal error like it doesn't existCode:fd = sceIoOpen("flash0:/vsh/resource/topmenu_plugin.rco", PSP_O_WRONLY | PSP_O_CREAT | PSP_O_TRUNC, 0777);
No, that would be opening the file in write mode, the actual flash0 needs to be assigned in write mode. So, first, you un-assign it, then re-assign it in write mode. Here's the code.Zitat:
Zitat von pspfreak101
sceIoUnassign("flash0:");
sceIoAssign("flash0:", "lflash0:0,0", "flashfat0:", IOASSIGN_RDWR, NULL, 0);
I have a question,
How would I have it "quit" or "exit" the game?
(By pressing triangle.)
2 ways, depending on how you wanted to work it, one would be to create another thread which waited for the triangle button to be pressed, and the it uses sceKernelExitGame(), the other method would be for use at selected periods only, and it would be the same, just adding it as needed.
I'm using sceIoOpen(filepath, PSP_O_WRONLY, 0777); but every time I open the file, the file becomes empty (0 bytes), why is this?
-Aura
thanks works great :) Finally a reason to be happy about a brickZitat:
Zitat von Judas
Lol, why on earth would you actually want to brick? I mean, I know you can restore with recovery with something as simple as a mising rco, and Pandora can recover then all (bar IPL damage), but still? Oh, and it wouldn't brick my PSP :p
-Aura
I'd don't use teh SCE file lib that much, but I think it's because PSP_O_WRONLY is similar to opening a file in "w" mode. It erases the file, or creates it if it doesn't exist. I think you need to open the file in append mode.Zitat:
Zitat von Auraomega
I think maybe PSP_O_APPEND would work.
The other modes are defined in pspiofilemgr_fcntl.h.
Or if you just want to open for reading, PSP_O_RDONLY.
They're all defined in pspiofilemgr_fcntl.h.
Ah, thanks guys, I never looked into that file, but I'll take a quick look over it now to see whats in there.
-Aura
sceKernelExitGameZitat:
Zitat von DJKPSP
might have to pass void, not sure?
sceKernelExitGame(); actually.
im sure he would have known that... :neutral:
Then why did he ask...
I guess he was trying to promote more communication between us :ROFL:
KK but i searched it up on google and i could not find what i was looking for. I have declered the variable at the start as an int but it still dosen't work could you please help.Zitat:
Zitat von placo23
Thanks,
Gavin/ITDemo
Gavin, you're gonna have to use CAST for that.Zitat:
Zitat von itdemo
Read this:
http://www.intap.net/~drw/cpp/cpp03_03.htm
Cheers
@Placo 23
I read it and then used it but i still get errors and one says "error invalid cast from type char* to type float. And btw i am using floats now sorry.
Thanks,
Gavin/ITDemo
Can I see your code mate? Snd me a pm.Zitat:
Zitat von itdemo
Cheers
I was referring to the post above mine :rolleyes:Zitat:
Zitat von Xsjado7
Im trying to compile a program and it gives me an error:
Where would I get/how can I install stat.h?Code:menu.c:5:55: error: /usr/include/sys/stat.h: No such file or directory
Just put stat.h on your "/usr/include/sys/" folder....
I don't know what that is, but it maybe something related tro the program you're trying to compile.
Cheers
i had that exact problem, can't remember how i had it fixed though, i think i didn't add the " 's in "/usr/include/sys/stat.h" :)
Edit: Nevermind, I get same error.
This is the code in the program:Zitat:
i had that exact problem, can't remember how i had it fixed though, i think i didn't add the " 's in "/usr/include/sys/stat.h"
Code:#include </usr/include/sys/stat.h>
But what program are you trying to compile? Did't it come with the .h?Zitat:
Zitat von Mirzab14
I am trying to compile World of Chaos.
It didn't come with it.
Well it doesn't seem to be used anyway. In the code it just says "addition for time", but there ain't nothing using this include on the code.Zitat:
Zitat von Mirzab14
Try to take it off and see what happens
I took it off and when I run the game, it tells me "Press X to continue". I press X and psp freezes, this happens only when I take out that include.
Ok, but I believe that when you leave the include there it doesn't even compile does it?Zitat:
Zitat von Mirzab14
The warnings are ok, it sgouldn't be a problem.
You may also try to remove the whole credits part just as a test to see it it's causing the problem. Or try to find an stat.h on google
Correct.Zitat:
Ok, but I believe that when you leave the include there it doesn't even compile does it?
Ill try taking out credits.
Edit: Yep, the problem is with credits. I took it out and app works perfectly now. What would I have to do to get credits to work without those errors?