Global variables have gotten a bad wrap. Like goto, comefrom, they are often considered harmful. Not everyone thinks action at a distance is spooky.

These days, they are often used as global constants, whether they're written that way or not. For instance, Rachel found the following global variable in some code she inherited.

  char *pSpaceChar[8] = {
      "",             // No Space Characters
      " ",            // One Space Character
      "  ",           // Two Space Characters
      "   ",          // Three Space Characters
      "    ",         // Four Space Characters
      "     ",        // Five Space Characters
      "      ",       // Six Space Characters
      "       " };    // Seven Space Characters

 

How might that be used in practice? She writes, "Although I like the CodeSODs where you imagine how on earth it could fit into a system, I couldn't resist giving an example."

  /* Adjust for decimal point */
  sprintf(pDuration, "%s%s", pSpaceChar[(9-iLength) * 2], pPointer); 

 

Incidentally, I do like the CodeSODs where you imagine how on earth it could fit into the system. Your mission, if you choose to accept it, is to describe uses for pSpaceChar; the most novel approach wins.