PDA

View Full Version : How do I output text to the prompt window as in a normal C program?



11-14-2003, 04:50 PM
I have no clue how to do this. I'm trying to debug my program and want to output the values in the array I'm using.

chowe6685
11-14-2003, 10:04 PM
printf("This goes to the console");

mikael_aronsson
11-15-2003, 03:01 AM
Or if you have a non console app and you do have a debugger you can use OutputDebugString(...)

Mikael

11-15-2003, 08:17 AM
I tried printf and then one of my variables as an argument and it crashed teh program.

dvm
11-15-2003, 09:01 AM
How do you create your window? (GLUT, Win32 API, Something else) What's your OS? (Windows, Linux). Post some code.

11-15-2003, 09:13 AM
I'm in Windows using GLUT. I used printf(currentsign);
which is just a char and it blew the program up.
void myinit(void)
{

glViewport(0,0,ww,wh);


/* Pick 2D clipping window to match size of X window
This choice avoids having to scale object coordinates
each time window is resized */

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0, (GLdouble) ww , 0.0, (GLdouble) wh , -1.0, 1.0);

/* set clear color to black and clear window */

glClearColor (0.8, 0.8, 0.8, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glFlush();
}

dvm
11-15-2003, 09:25 AM
printf is used as follows:



char currentsign = 'd'; //just a random letter to initialize the variable

printf("Print a character: %c", currentsign);

Also I find sprintf pretty handy sometimes:



char str[50];
int someInt = 5;

sprintf(str, "The Int is: %d", someInt);
printf("%s", str);

especially when you want to print bitmap character 'n' stuff.
Anyway have you initialized you variable?



[This message has been edited by moucard (edited 11-15-2003).]

11-15-2003, 07:52 PM
yes, the variable is initialized