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; Zitat von psphacker12. How can I fix that? add a ; to the end of the last line....
-
10-07-2006, 03:12 PM #1141Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
Zitat von psphacker12.
add a ; to the end of the last line.
-
10-07-2006, 03:13 PM #1142likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
I've been looking over "Thinking like a computer scientist [C++]" and I was wondering should I use cout<< or printf??
Zitat von head_54us
-
10-07-2006, 03:19 PM #1143QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
Use printf. Getting the STL library to work with the PSP compiler is a bit of work.
-
10-07-2006, 03:21 PM #1144likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
couldnt i just do this??
Zitat von head_54us
or would that give me an error?Code:int nums() { funcs();
im trying it now. :)
-
10-07-2006, 03:23 PM #1145QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
You are just calling the function. It will still give the same error. Read about variable scope.
-
10-07-2006, 03:33 PM #1146QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- Germany
- Beiträge
- 216
- Points
- 4.511
- Level
- 42
- Downloads
- 0
- Uploads
- 0
That works, thank you!
Zitat von head_54us
-
10-07-2006, 06:10 PM #1147sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
I believe the fist book you mentioned can be read for free here: http://www.fis.cinvestav.mx/~jccoron...guageAnsiC.pdf
Zitat von head_54us
-
10-07-2006, 06:20 PM #1148likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
when I press 'x' it doesnt update the info..Code:#include <pspdisplay.h> #include <pspgu.h> #include <pspkernel.h> #include <pspctrl.h> #include <pspdebug.h> #include <stdlib.h> #include <stdio.h> #include <math.h> #include <time.h> #include <png.h> #include "graphics.h" #define printf pspDebugScreenPrintf #define dprint pspDebugScreenPrintf #define true 1 #define false !true #define bool int #define NULL 0 PSP_MODULE_INFO("???", 0, 1, 1); /* Standard callbacks */ int exit_callback(int arg1, int arg2, void *common) { sceKernelExitGame(); return 0; } int CallbackThread(SceSize args, void *argp) { int cbid; cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL); sceKernelRegisterExitCallback(cbid); sceKernelSleepThreadCB(); return 0; } int SetupCallbacks(void) { int thid = 0; thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0); if(thid >= 0) { sceKernelStartThread(thid, 0, 0); } return thid; } int nums() { int rn0 = 0; int rn1 = 0; int rn2 = 0; bool status = 0; SceCtrlData pad; sceCtrlPeekBufferPositive(&pad, 1); srand(sceKernelLibcTime(NULL)); if (pad.Buttons != 0){ if(pad.Buttons && PSP_CTRL_CROSS) { rn0=rand()%1,3; rn1=rand()%1,3; rn2=rand()%1,3; } } if (rn0 == 1 && rn1 == 1 && rn2 == 1) { pspDebugScreenSetXY(0,2); pspDebugScreenSetBackColor(0x00FF0000); pspDebugScreenSetTextColor(0x00000000); pspDebugScreenPrintf("You won.\n"); pspDebugScreenPrintf("Press 'X' to restart.\n"); if(pad.Buttons & PSP_CTRL_CROSS) { nums(); } } if (rn0 == 2 && rn1 == 2 && rn2 == 2) { pspDebugScreenSetXY(0,2); pspDebugScreenSetBackColor(0x00FF0000); pspDebugScreenSetTextColor(0x00000000); pspDebugScreenPrintf("You won.\n"); pspDebugScreenPrintf("Press 'X' to restart.\n"); if(pad.Buttons & PSP_CTRL_CROSS) { nums(); } } if (rn0 == 3 && rn1 == 3 && rn2 ==3) { pspDebugScreenSetXY(0,2); pspDebugScreenSetBackColor(0x00FF0000); pspDebugScreenSetTextColor(0x00000000); pspDebugScreenPrintf("You won.\n"); pspDebugScreenPrintf("Press 'X' to restart.\n"); if(pad.Buttons & PSP_CTRL_CROSS) { nums(); } } if(rn0 == 0 && rn1 == 0 && rn2 == 0) { pspDebugScreenSetXY(0,2); pspDebugScreenClear(); pspDebugScreenSetBackColor(0x00FF0000); pspDebugScreenSetTextColor(0x00000000); pspDebugScreenPrintf("Press |`'~X~'`| to start\n"); if(pad.Buttons && PSP_CTRL_CROSS) { pspDebugScreenSetXY(0,2); pspDebugScreenClear(); pspDebugScreenSetBackColor(0x00FF0000); pspDebugScreenSetTextColor(0x00000000); rn0=rand()%1,3; rn1=rand()%1,3; rn2=rand()%1,3; } } } int main(void) { /* main functions */ pspDebugScreenInit(); SetupCallbacks(); while(true) { /* while loop */ nums(); } return 0; }
-
10-08-2006, 03:08 AM #1149
- Registriert seit
- Aug 2006
- Beiträge
- 10
- Points
- 3.787
- Level
- 38
- Downloads
- 0
- Uploads
- 0
Hey, sup guys? well I need help.
Im trying to change DevHook Launcher font with this guide: Release: FLIB Truetype font library in C
And its always dont working If someone can send me the DevHook Launcher SDK WITH ANY OTHER FONT And tell me where im chaging it again I would be very happy.
-
10-08-2006, 04:58 AM #1150QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
psp
12: You have been told this many times:
&& - logical AND
& - Bitwise AND.
Bronx: That link looks VERY illegal.
-
10-08-2006, 05:02 AM #1151Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
How can I change which folder cygwin starts in?
for me it starts in 'home/my name'
but I wan't it to start in 'home/myname' tried renaming the my name folder to myname and then changing the name of my xp user to myname instead of my name.
but cygwin just created a new folder still.
-
10-08-2006, 06:31 AM #1152Developer

- Registriert seit
- Oct 2005
- Ort
- Boston, MA
- Beiträge
- 1.389
- Points
- 14.378
- Level
- 77
- Downloads
- 0
- Uploads
- 0
Hey,
Anybody know if normal PC SDL is exactly the same as PSP SDL.
If not, whats the difference?
--Vaza
-
10-08-2006, 06:35 AM #1153AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
I believe so, haven't worked that much with it though.
Zitat von Vaza
-
10-08-2006, 08:00 AM #1154likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
hah lol ur not prem anymore
Zitat von homer
-
10-08-2006, 08:02 AM #1155I'm Baaaack!

- Registriert seit
- May 2006
- Ort
- Nowhere
- Beiträge
- 2.186
- Points
- 17.067
- Level
- 83
- Downloads
- 0
- Uploads
- 0
First of all, why would you laugh at him for not being premium? And second of all, yes he is. He just changed the color of his name.
Zitat von psphacker12.

-
10-08-2006, 08:06 AM #1156AKA Homer

- Registriert seit
- Jan 2006
- Ort
- Sweden
- Beiträge
- 1.779
- Points
- 12.596
- Level
- 73
- Downloads
- 0
- Uploads
- 0
STFU you n00b.
Zitat von psphacker12.
I am premium, I just changed the color to dark blue.
-
10-08-2006, 08:08 AM #1157likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
:Argh: sorry for laughing at you
Zitat von homer
-
10-08-2006, 08:12 AM #1158sceKernelExitGame();
- Registriert seit
- Jan 2006
- Ort
- New York
- Beiträge
- 3.126
- Points
- 19.955
- Level
- 89
- Downloads
- 0
- Uploads
- 0
The main differeces I know of is the control mapping and that a lot of SDL is done in software insteado hardware. The control mapping for SDL is all using a 'joystick' instead of buttons. Check out this thread: http://forums.ps2dev.org/viewtopic.p...49c129a3f2328f
Zitat von Vaza
@psp
12, Homer still has a sig, he HAS to be premium/dev... Use your common sense nd stop spamming the forums
-
10-08-2006, 08:48 AM #1159likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
okay I successfully installed the freetype lib
but when I try to compile it gives me this.
-
10-08-2006, 08:50 AM #1160Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
Add flib.o to the OBJS line in your makefile.
You'll probably need graphics.o and framebuffer.o 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
-
10-08-2006, 08:58 AM #1161likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
ok i included flib.o graphics.o and framebuffer.o
but it gives me an error with flib
-
10-08-2006, 09:17 AM #1162Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
beter copy and pasta you errors here;) and btw there is something wrong with your flib.o
-= Double Post =-
some prob's
it flips the text(je hebt vermenigvuldigen gekozen) 10.000 times on screen ,lolinline void vermenigvuldigen()
{ pspDebugScreenClear();
x=0;
while(1) {
printf("\n\n\n\n\n\n\n je hebt vermenigvuldigen gekozen\n");
if (x>=50) {
printf(" bezig met opstarten");
}
if (x>200) {
printf(",klaar");
}
if (x>250) {
pspDebugScreenClear();
vermenigvuldigenb();
}
}
}
and the rest it dont
prob2
i let change the functions by pressing triangle
but when you hold it , it change , change and change , it only ahve to change ones
the prob is
it loads another loop while pressing triangle and in the next loop it does the same , so it continues.....Geändert von hallo007 (10-08-2006 um 09:18 AM Uhr) Grund: Automerged Doublepost
-
10-08-2006, 09:18 AM #1163likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
i posted a pic..
press back on your browser then forward..
that should make the image normal size
-
10-08-2006, 09:27 AM #1164QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
hallo007:
Flipping heck... where do I start....Code:inline void vermenigvuldigen() { pspDebugScreenClear(); x=0; while(1) { printf("\n\n\n\n\n\n\n je hebt vermenigvuldigen gekozen\n"); if (x>=50) { printf(" bezig met opstarten"); } if (x>200) { printf(",klaar"); } if (x>250) { pspDebugScreenClear(); vermenigvuldigenb(); } } }
1) You are inlining a function that really doesn't need to be inlined. Don't overuse the inline keyword and avoid premature optimisation.
2) You are using an infinite loop (while(1) ) with no possbile exit condition.
3) x is always going to be 0 before the while loop begins therefore none of the if statements will equal true.
-
10-08-2006, 09:30 AM #1165Heroes never die

- Registriert seit
- Aug 2006
- Ort
- ...........
- Beiträge
- 1.323
- Points
- 8.645
- Level
- 62
- Downloads
- 0
- Uploads
- 0
2/it loads another function so why exit?
Zitat von head_54us
3/ , how do i let it be true
-
10-08-2006, 09:37 AM #1166likes kittens....awww....
- Registriert seit
- Sep 2006
- Ort
- Detroit
- Beiträge
- 628
- Points
- 6.975
- Level
- 55
- Downloads
- 0
- Uploads
- 0
put
Zitat von hallo007
in your while loop.Code:int x=0;
-= Double Post =-
Hey i have a question..
In gimp, you can save images as image.c so cant you compile that image within the EBOOT to save memory space??Geändert von psphacker12. (10-08-2006 um 09:38 AM Uhr) Grund: Automerged Doublepost
-
10-08-2006, 09:38 AM #1167Developer

- Registriert seit
- Feb 2006
- Ort
- Norway
- Beiträge
- 384
- Points
- 5.359
- Level
- 47
- Downloads
- 0
- Uploads
- 0
if (x>=50)
Zitat von hallo007
is true if x is larger then or equal to 50.
but since you never make x increase nothing else will happen. add x++; or somthin
-
10-08-2006, 09:40 AM #1168QJ Gamer Silver

- Registriert seit
- Jun 2006
- Ort
- UK
- Beiträge
- 2.326
- Points
- 10.263
- Level
- 67
- Downloads
- 0
- Uploads
- 0
psp
12.: Incorrect
hallo007: It doesn't even load another function since x is always 0 when entering the while loop.
This:
Might as well be:Code:inline void vermenigvuldigen() { pspDebugScreenClear(); x=0; while(1) { printf("\n\n\n\n\n\n\n je hebt vermenigvuldigen gekozen\n"); if (x>=50) { printf(" bezig met opstarten"); } if (x>200) { printf(",klaar"); } if (x>250) { pspDebugScreenClear(); vermenigvuldigenb(); } } }
It won't ever leave the while loop.Code:inline void vermenigvuldigen() { pspDebugScreenClear(); x=0; while(1) { printf("\n\n\n\n\n\n\n je hebt vermenigvuldigen gekozen\n"); } }
-
10-08-2006, 09:59 AM #1169Developer

- Registriert seit
- Mar 2006
- Beiträge
- 1.026
- Points
- 7.577
- Level
- 58
- Downloads
- 0
- Uploads
- 0
psp
12: Your freetype headers are in the wrong directory. They should be in:
I seem to remember the ps2dev.org SVN putting them in a freetype2 folder or something like that.Code:usr\local\pspdev\psp\include\freetype
Just copy them into the usr\local\pspdev\psp\incl ude\freetype directory.
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
-
10-08-2006, 10:11 AM #1170QJ Gamer Blue
- Registriert seit
- Sep 2006
- Ort
- Germany
- Beiträge
- 216
- Points
- 4.511
- Level
- 42
- Downloads
- 0
- Uploads
- 0
Socket-programming
Socket-programming
Hi,
I'm doing some networkprogramming right now; The connecting works fine, but when it comes to the data exchange I'm having some issues; What he shall do is:
1.) Client connects to server (works)
2.) Client sends "<command>get_artists </command>" (works)
3.) Server recieves message and prints it (works)
4.) Client sends "<command>get_albums</command>" (works)
5.) Server recieves message and prints it (works)
6.) Client starts recieving (while-loop) (he starts recieving but never actually recieves something)
7.) Server answers (never sends anything)
Server code:
Client code:Code:if(listen(sock, 5) == -1 ) error_exit("Error listening"); printf("Server ready - waiting for requests\n"); for (;;) { len = sizeof(client); // client = sockaddr_in fd = accept(sock, (struct sockaddr*)&client, &len); if (fd < 0) error_exit("Error accepting"); printf("Incloming request from %s\n", inet_ntoa(client.sin_addr)); while(rc!=SOCKET_ERROR) { rc=recv(fd,buf,256,0); if(rc==0) { printf("Client closed the connection...\n"); break; } if(rc==SOCKET_ERROR) { printf("Error: recv, error-code: %d\n",WSAGetLastError()); break; } buf[rc]='\0'; printf("Client sent: %s\n",buf); } printf("Sending answer...\n"); sprintf(buf2,"%s\n",buf); rc=send(fd,buf2,strlen(buf2),0); printf("Closing connection...\n"); closesocket(fd);
what he does is, on the server, recieving and displaying the messages (nothing else), and on the client, he sends the 2 messages, displays 'reciecing and does nothing moreCode:command = "<command>get_artists</command>"; command_len = strlen(command); command2 = "<command>get_albums</command>"; command2_len = strlen(command); if (send(socket, command, command_len, 0) != command_len) { printf("send() sent a different length of bytes than expected!\n"); // needs real exceptionhandling return; } printf("sending command get_artists...\n"); if (send(socket, command2, command2_len, 0) != command_len) { printf("send() sent a different length of bytes than expected!\n"); // needs real exceptionhandling return; } printf("sending command get_albums...\n"); printf("recieving...\n"); while(rc!=SOCKET_ERROR) { rc=recv(socket,buf,4096,0); // muss noch variabel gemacht werden buf[rc]='\0'; if(rc==0) { printf("Server has closed the connnection\n"); break; } if(rc==SOCKET_ERROR) { printf("Error: recv, error-code: %s\n",strerror(errno)); break; } printf("%s\n", buf); strcat(recivedMessage, buf); } close(sock);


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