I got a question:
I want to use a macro in a GLUT function, i.a.:
#define CURRENT_DATE (23. May 2002)
and want to use it within the glutCreateWindow();
How to use it? My compiler won’t allow me
glutCreateWindow("Current date is: "CURRENT_DATE);
I can’t find any information about it…
please help me!
int main(int argc, char **argv)
t = time(NULL);
c = (char)malloc(45*sizeof(char));
sprintf(c, “Current date is: %s”,asctime(localtime(&t)));
w = glutCreateWindow©;
Thanx for that… I’ll have to try it!
[This message has been edited by Moritz (edited 05-25-2002).]
Hmm… the idea is good, but my realisation isn’t that “efficiant”.
May you could help me again. (BTW: I don’t need the date of compilation, I just need the date of the source release.)
So here’s my source:
#define BUILD “0001”
#define BUILD_DATE “23.05.2002”
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
strcpy (window_name, "Project One - Build: “);
strcat (window_name, BUILD);
strcat (window_name, " [”);
strcat (window_name, BUILD_DATE);
strcat (window_name, “]”);
Is there any way to use C++ instead of C? Any faster way?
BTW: It currently works! My window name is "Project one - Build 0001 [23.05.2002]
But it looks quit unefficiant
If your using mfc you can use CString:
str = "Project One - Build: ";
str += BUILD;
str += BUILD_DATE;
there are other ways. but you basically have
it right. I’d suggest bumping the char array
up to 100 bytes or so so you never overwrite it.