i would like to create a function that returns the binary representation of a decimal in a string. i tried many think but i didn't succed .
An other point i can't load the iostream header in /usr/include/pspdev/include/c++/4.1.0 cause it returns error. Is it the good file or must i search it in an other directory ?
Thanx for your help ,
Jim wrote:The PSP is almost certainly not the best platform to start learning to program C.
Jim
Really? I would have thought so... Is that for lack of official documentation?
What is?
Well C itself is not the easiest programming language, and you add to that an unusual environment with little debugging capacities and many more reasons for your application not to work...
Obviously it's easier to learn C on a Linux or Unix machine...
PS : use english for your variable names, try to avoid french, you never know, people might want to reuse your code one day ;)
The remainder var isn't initialized in the case the if() code block is executed. This means that it will have an undefined value that will almost certainly cause a buffer overflow in the sprintf() as resultat is only 5 characters long, but the %X can generate up to eight characters.
You should define them as
int remainder = 0;
char resultat[9];
You need an extra char in resultat for the null terminating byte.
Why are you including iostream? Do you need it for some other part of your program? The code snippet you posted only needs stdio.h. Perhaps you're actually building a C++ program, or you're using the C compiler by mistake?
Good places to start with C and/or C++.
Windows:
DevC++
Visual Studio Express
Linux:
GCC
If you really insist on learning on the PSP, look at the example programs that come with the SDK. To check out the full SDK, use subversion (or a subversion client on Windows) to get it like this:
That will make a directory called psp in the current directory where you are which has all the different subdirectories from the psp sdk main trunk. You'll find various libraries for the PSP as well as the SDK itself. In the SDK directory will be examples.
You could also look at the various homebrew games and apps released as most of them come with the source code.
As others have mentioned, you're better off LEARNING c or c++ for linux or Windows first, then moving to c or c++ for PSP. It's much easier that way since the PSP is a really oddball cross-compiling environment. Learn c first, then c++. Most c++ books assume you know c well before even opening the c++ book as c++ is derived from c.
Ok , with a little of change and some functions that i picked on the web my first hombrew begin to work. it's an app to control an IR helicopter "the picooz".. After some code lines , i could start the graphic part.
1. you're heading for a binary representation of a number, while you're using %X which is HEX representation...
2. your code has an IF statement, while it should have had a WHILE one...