lesson 13 problem
Lesson13 (wgl font tut..)
in "int DrawGLScene(GLvoid)":
..
glRasterPos2f(-0.45f+0.05f*float(cos(cnt1)), 0.32f*float(sin(cnt2)));
char* test="test"; //my code
strcat(test, "-"); //my code
glPrint(test); //my code
cnt1+=0.051f;
..
"test----" is displayed on screen, why not "test-"?
Try doing strcpy(test,"test") instead of directly assigning the string.
As I see it, when you assign a value directly, it doesn''t change the length of the array. But when you do strcpy(), it resizes the character array to the length of the string being copied.
You can try freeing the array manually, and then assigning the new value directly, it should give the same result. But in practice try to stick to the available string functions.
You can try freeing the array manually, and then assigning the new value directly, it should give the same result. But in practice try to stick to the available string functions.
December 03, 2001 05:29 PM
first off you should never cpy strings into arrays that are not big enough to hold the entire string. since you are corrupting other pieces of memeory which can lead to protection faults or worse just screw up important varibles and keep you confused why things dont work when they should.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement