C/C++ Programming Help Thread
This is a discussion on C/C++ Programming Help Thread within the PSP Development Forum forums, part of the PSP Development, Hacks, and Homebrew category; Ok i've been going over it and over it, looks good but I can't find out whats wrong with the ...
-
01-04-2007, 09:45 PM #2461QJ Gamer Blue
- Registriert seit
- Jan 2006
- Ort
- CO
- Beiträge
- 150
- Points
- 8.686
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
psp-programming lesson5
Ok i've been going over it and over it, looks good but I can't find out whats wrong with the source maybe someone could tell me.
Spoiler for code:
my compiler output errors are
Spoiler for errors:
This is driving me crazy and I'm sure it will turn out to be something simple...I just know it. :Argh:
-
01-04-2007, 10:42 PM #2462QJ Gamer Bronze

- Registriert seit
- Jun 2006
- Beiträge
- 144
- Points
- 7.047
- Level
- 55
- Downloads
- 0
- Uploads
- 0
Division bar is in the wrong direction.... =_=''#define RGB(r,g,b) ((r) \ ((g)<<8) \ ((b)<<16))
\ = BACKSLASH -> escape character.
/ = SLASH -> division
-
01-04-2007, 11:30 PM #2463QJ Gamer Blue
- Registriert seit
- Jan 2006
- Ort
- CO
- Beiträge
- 150
- Points
- 8.686
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
lol...you helped me again. Man Im not cut and pasteing but thats the way it is in the tutorial. I cant beleave I didnt think about that because of useing \n with strings and all. GEZZ!
Ok found out it should be pipes (shift+\), I was wondering cause dividing there doesnt make sence.Geändert von HYde (01-05-2007 um 12:22 AM Uhr)
-
01-05-2007, 02:51 AM #2464Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
how do you read and print the bytes of an file?(print is not a problem;))
find it;)
(here http://www.psp-programming.com/code/...lesize_example)
-= Double Post =-
some warnings
the codeCode:filebrowser/file_browser.c: In function 'checkspace': filebrowser/file_browser.c:117: warning: passing argument 1 of 'stat' makes poin ter from integer without a cast filebrowser/file_browser.c:118: warning: format '%d' expects type 'int', but arg ument 2 has type 'off_t' filebrowser/file_browser.c:121: warning: 'return' with a value, in function retu rning void
Code:void checkspace() { struct stat fileStats; if (stat(current_selection, &fileStats) == 0) { printf("File size is %d\n", fileStats.st_size); } return(0); }Geändert von hallo007 (01-05-2007 um 02:51 AM Uhr) Grund: Automerged Doublepost
-
01-05-2007, 08:32 AM #2465Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
blargh, I made a function to free a linked list, but it keeps crashing..
Every "line" of the list have been allocated using malloc. I bet theres some simple reason for it crashing, but I just can't find anything wrong.Code:typedef struct ObjectList { Model *m; float x, y, z; float rx, ry, rz; ObjectList *next; }; void WipeObjectList(ObjectList *p) { if(p == 0) return; if(p->next != 0) WipeObjectList(p->next); free(p); }
-
01-05-2007, 10:46 AM #2466QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Most likely this is the probem. When you create a new ObjectList struct, do you assign 'next' NULL or 0?Code:if(p->next != 0)
[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
01-06-2007, 07:28 AM #2467Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
still not fixed:s
Zitat von hallo007
-
01-06-2007, 09:23 AM #2468Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
0.
Zitat von yaustar
I thought NULL was defined to be 0 though? Maybe I were lied to.
anyway, shortened version of my code for makeing a new list is;
Code:void AddObject2List(ObjectList *p) { if(p->next == 0) { p->next = (ObjectList*) malloc(sizeof(ObjectList)); p = p->next; p->next = 0; } else { AddObject2List(p->next); } }
-
01-06-2007, 09:32 AM #2469QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Not always, always prefer NULL over 0.I thought NULL was defined to be 0 though? Maybe I were lied to.
Can you post up some sample code using your list strcut and all the functions that you use. That way I can debug it properly on my machine.[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
01-06-2007, 09:37 AM #2470QJ Gamer Silver
- Registriert seit
- Oct 2005
- Ort
- Sheffield, UK
- Beiträge
- 844
- Points
- 8.201
- Level
- 61
- Downloads
- 0
- Uploads
- 0
void functions dont return anything :)
Zitat von hallo007
-
01-06-2007, 09:40 AM #2471Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
yeah i know that warniung ofcourse;)
but the other warnings , any idea?
-
01-06-2007, 09:50 AM #2472QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
void functions don't need a return value.Code:void checkspace() { struct stat fileStats; if (stat(current_selection, &fileStats) == 0) { printf("File size is %d\n", fileStats.st_size); } return(0); }
You need to type cast fileStats.st_size to an integer.
You have both a struct and a function named exactly the same thing. Very bad design.
stat function's first parameter is expecting a pointer not an integer.[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
01-06-2007, 09:54 AM #2473Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
functions: http://www.freewebs.com/waterbottle123/excode.c
Zitat von yaustar
code:
AddObjects2List( 0, 0, 0, 0, 0, -32, 0, 0, 6, Asphalt, rootGround );//add 6 lines to the list.
pspDebugScreenPrintf("%d" , CountList(rootGround)); //prints amount of lines
if(pad.Buttons & PSP_CTRL_START) WipeObjectList(rootGround->next); //crashes
edit: also Asphalt is a Model,
Code:typedef struct { Vertextex *o; CTGATexture *tex; int size; int type; float sx, sy, sz; float maxdist; } Model;
-
01-06-2007, 10:09 AM #2474QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Works fine for me. No crashes.Code:#include <stdlib.h> typedef struct ObjectList { float x, y, z; float rx, ry, rz; ObjectList *next; }; //Fills a line in an ObjectList. void AO2L( float x, float y, float z, float rx, float rz, ObjectList *p ) { p->x = x; p->y = y; p->z = z; p->rx = rx; p->rz = rz; p->next = NULL; } //Adds new lines to an ObjectList, and fills them. void AddObjects2List( float sx, float sy, float sz, float dx, float dy, float dz, float rx, float rz, int amt, ObjectList *p ) { if(p->next == NULL) { p->next = (ObjectList*) malloc(sizeof(ObjectList)); p = p->next; AO2L( sx+=dx, sy+=dy, sz+=dz, rx, rz, p ); amt--; if(amt>0) AddObjects2List( sx, sy, sz, dx, dy, dz, rx, rz, amt, p ); } else { AddObjects2List( sx, sy, sz, dx, dy, dz, rx, rz, amt, p->next ); } } void WipeObjectList(ObjectList *p) { if(p == NULL) return; if(p->next != NULL) WipeObjectList(p->next); free(p); } int CountList(ObjectList *p) { int counter = 0; while(p != NULL) { counter++; p = p->next; } return counter; } int main( ) { ObjectList *rootGround = (ObjectList*) malloc(sizeof(ObjectList)); rootGround->next = NULL; AddObjects2List( 0, 0, 0, 0, 0, -32, 0, 0, 6, rootGround ); WipeObjectList(rootGround ->next); return 0; }[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
01-06-2007, 10:23 AM #2475Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
Weird.. :/
Zitat von yaustar
-
01-06-2007, 12:12 PM #2476likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
How to copy a file ?
-
01-06-2007, 12:32 PM #2477QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
You google:
Zitat von psphacker12.
http://www.google.co.uk/search?q=fop...en-US:official
First hit:
http://www.macdonald.egate.net/CompSci/hfileio.html[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]
-
01-06-2007, 01:02 PM #2478likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
thx yaustar
-
01-06-2007, 03:49 PM #2479words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
psp
- The time it took you to type up and post that question, then waiting, could have been spent implementing the file copying after a quick google... Try it next time ;) Its much faster and doesnt make you look like you're depending on others (hint)

...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
01-07-2007, 05:43 AM #2480Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
how do you write your own files to flash1?? i can only write teh registery files and i want to flash a mp3 to it
evertime i try it loads the mp3 but dont flash it:s
any sugestions?
-
01-07-2007, 04:59 PM #2481words are stones in my <3

- Registriert seit
- Jul 2005
- Ort
- Spokane
- Beiträge
- 5.008
- Points
- 35.274
- Level
- 100
- My Mood
-
- Downloads
- 1
- Uploads
- 0
You write correctly using 3rd grade punctuation and spelling skills...
Consult Art for a working answer...
...at what speed must I live.. to be able to see you again?...
Projects
You can support my Open World 3D RPG for PSP by voting for it here
-
01-08-2007, 05:15 PM #2482Developer

- Registriert seit
- Sep 2005
- Ort
- Sweden
- Beiträge
- 941
- Points
- 10.075
- Level
- 67
- Downloads
- 0
- Uploads
- 0
You probably will have to mount flash1 like flash0.
Zitat von hallo007
-
01-08-2007, 08:14 PM #2483QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- Australia - A.C.T.
- Beiträge
- 1.517
- Points
- 9.253
- Level
- 64
- Downloads
- 0
- Uploads
- 0
is there a way i can get my psp to act like x is being pressed when i press select & note
something like
if (pad_data.Buttons & PSP_CTRL_SELECT & PSP_CTRL_NOTE){
PSP_CTRL_CROSS
}
Spoiler for LOL:
-
01-08-2007, 08:49 PM #2484Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
Not without hooking some functions.
Maybe if you explained exactly what you are trying to achieve we could offer an alternative idea.
Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
01-08-2007, 09:28 PM #2485QJ Gamer Green
- Registriert seit
- Feb 2006
- Ort
- Australia - A.C.T.
- Beiträge
- 1.517
- Points
- 9.253
- Level
- 64
- Downloads
- 0
- Uploads
- 0
basicly say one of your psp buttons stoped working this could be used to make a 2 buttons pressed together do what that button did befor.
-= Double Post =-
would this code be able to help with hooking
http://0okm.blogspot.com/2006/11/psp...-released.htmlGeändert von mafia1ft (01-08-2007 um 09:28 PM Uhr) Grund: Automerged Doublepost
Spoiler for LOL:
-
01-09-2007, 01:47 AM #2486Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
Yes. There's always RemaPSP as an alternative too.

Check out my homebrew & C tutorials at http://insomniac.0x89.org/
Coder formerly known as Insomniac197
tshirtz: what is irshell ??
Atarian_: it's where people who work for the IRS go when they die
-
01-09-2007, 05:27 AM #2487Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
i did
Zitat von SodR
-
01-09-2007, 11:16 AM #2488QJ Gamer Green
- Registriert seit
- Jul 2006
- Ort
- USA SC/NC
- Beiträge
- 699
- Points
- 5.712
- Level
- 48
- Downloads
- 0
- Uploads
- 0
Zitat von hallo007
Spoiler for Copy a file to flash1:Geändert von Moca (01-12-2007 um 10:30 PM Uhr)
[CODE]Random Facts:
irc://irc.malloc.us #wtf #**********
[/CODE]
[SIZE="6"][FONT="Century Gothic"][COLOR="Blue"][URL="http://forums.**********.net"]http://forums.**********.net[/URL][/COLOR][/FONT][/SIZE]
-
01-09-2007, 08:48 PM #2489QJ Gamer Blue
- Registriert seit
- Jan 2006
- Ort
- CO
- Beiträge
- 150
- Points
- 8.686
- Level
- 62
- My Mood
-
- Downloads
- 0
- Uploads
- 0
Program Console Window! Some close some don't.
Some of you may know that in some Compiler IDE's, you have to tell the program your writing to wait for you. So that you can see your output.
With C I use getchar(); "mainly for simple programs, or just in the develpoment process" What I have here is two simple programs, the first one everyone knows.
Spoiler for Example :: Hello World:
Getting to my point and question
If I compile and run Hello World it paused and waited for me to hit a key. My second example I did.
Spoiler for Example :: Multiply two numbers:
When I go to run it I will enter my two numbers, but when I get the output. The console closes before I can see it. This has been bothering me all day. With no answers from goggle ...so far! I know some of you may say just to use Visual C++ or something of that nature, and it will pause it for me. Thats all good! What I have been doing lately is going through some different IDE's. Especially for use with Cygwin for PSP development. "Plus scrapping some of the rust off thats collected on my programming knowledge"
Maybe thats just it and I'm not seeing the obvious. Maybe someone can put my mind to ease. And I hope this wasn't a waste of time. Sorry if it was, I do need some sleep! :Argh:
-
01-10-2007, 01:38 AM #2490QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Honestly, I would just use another scanf instead of getchar.
I be guessing you are using DevCpp for the IDE, I personally prefer Code::Blocks myself.[Blog] [Portfolio]
[Homebrew Illuminati - Serious Homebrew Development Forums]
[I want to make Homebrew FAQ] [How I broke into the Games Industry]
[Programming Book List] [Programming Article List]


LinkBack URL
About LinkBacks
Mit Zitat antworten

Hello everyone I am new here and I am glad to be part of this amazing community and I think there...
New to forum