0

How can I print a buffer in my stdout for debugging purposes? I'm currently a beginner working with OpenGL within XCode (for an iOS app) and have the below lines of code.

GLubyte *buffer = (GLubyte *)malloc(myDataLength);
glReadPixels(0, 0, 320, 480, GL_RGBA, GL_UNSIGNED_BYTE, buffer);

I'd simply like to print to the console the buffer although when trying: fprintf(stderr, buffer); I receive an error "No matching function for call to 'fprintf'.

Nicol Bolas
  • 449,505
  • 63
  • 781
  • 982
user3197788
  • 165
  • 4
  • 14

1 Answers1

-2

"fprintf" needs at least 3 argumens (output file, string format, argument) while you provide only 2. C++ compiler tells you that cannot find a matching signature of fprintf with 2 arguments. Besides, there is one more issue to be solved. The buffer probably contains non printable characters so the correct call of fprintf may will not give you the expected result. I would suggest to use a custom buffer printing method maybe something like this Printing char buffer in hex array

Community
  • 1
  • 1