Advertisement

Whats this part of this code mean / do?

Started by March 30, 2003 12:10 AM
2 comments, last by Xnin 21 years, 11 months ago
Hey, im looking at adding fonts to my opengl window (using the lighthouse tutorial) and im wondering what some part of it actually does. Heres the code:

void renderBitmapCharacher(float x, float y, float z, void *font,char *string)
{
  
  char *c;
  glRasterPos3f(x, y,z);
  for (c=string; *c != ''\0''; c++) {
    glutBitmapCharacter(font, *c);
  }
}
 
Ok, the thing i dont understnad is why are they adding the
*c != ''\0'' 
and what does it mean? Thanks in advance
in c strings are terminated by the null character
which is ''\0''

hence they are iterating until the end of the string is encountered
Advertisement
if memory serves me correctly then /0 is the null terminating character. At the end of each string there is a null terminating character which tells cpp that this is the end of the string. Basically your loop starts at the beginning of your string and stops at the end, processing each character.

*c = ''/0'' means that if the data at the place where c points to is a null terminating character then get out of the loop because you are at the end of the string.
great, thanks

This topic is closed to new replies.

Advertisement