GP32 Printf And Cout


They have both have the same function, but work in different ways.

printf is the c way of doing things.
cout is the c++ way of doing things.

printf is a function that will output to standard out by default. You give it a format string and a set of varibles
e.g. printf("This will print the value of variable a in decimal format %d\n", a);

cout is an object representing the standard out. You use it like this:

cout << "This will print the value of variable a in decimal format " << a << "\n";

printf is better at number formatting (at least I find it is), cout is better at handling lots of random datatypes.

However, this is all somewhat irrelevant, as the GP32 has no standard out.
The closest you get is sprintf, which works the same asz printf but outputs to a string.
e.g.

char buffer[200];
sprintf(buffer, "This will print the value of variable a in decimal format%d\n", a);
GpTextOut(NULL, &gpDraw[nflip], buffer, 10, 100, 0xff) ; //probably got the syntax completely wrong here, done from memory.
 
Back
Top