Count yourself blessed if you’ve never had to spell your name over the phone. Or perhaps you’re named Mary Smith, but you live on a street or in a city you must constantly spell aloud. If so, you resort to your own spelling alphabet, something like, “N, as in Nancy” or “K, as in knife.” As a programmer, you can ease this frustration by reading this chapter, where you
Understand the NATO phonetic alphabet and why they even bother.
Learn that natto in Japanese is a delicious, fermented soybean paste.
The last bullet point isn’t covered in this chapter. I just enjoy eating natto, and now I can write it off as a business expense.
The glorious conclusion to all this mayhem is to not only learn some new programming tricks but also proudly spell words aloud by saying “November” instead of “Nancy.”
Beyond being a handy nickname for anyone named Nathaniel, NATO stands for the North Atlantic Treaty Organization. It’s a group of countries who are members of a mutual defense pact.
Established after World War II, blah-blah-blah. I could wax on, but the point is that NATO requires some commonality between its member states. You know, so that when Hans is short on ammo, Pierre can offer him bullets and they fit into the gun. Stuff like that.
One common item shared between NATO countries is a way to spell things out loud. That way, Hans doesn’t need to say, “Bullets! That’s B, as in bratwurst; U, as in über; L, as in lederhosen. . . .” And so on. Instead, Hans says, “Bravo, Uniform, Lima, Lima, Echo, Tango.” This way, Pierre can understand Hans, even over all the surrounding gunfire.
Table 3.1 lists the NATO phonetic alphabet, describing each letter with its corresponding word. The words are chosen to be unique and not easily misunderstood. Two of the words (Alfa and Juliett) are misspelled on purpose to avoid being confusing—and to be confusing.
NATO isn’t the only phonetic alphabet, but it’s perhaps the most common. The point is consistency. As programmer, you don’t need to memorize any of these words, though as a nerd, you probably will. Still, it’s the program that can output NATO code—or translate it back into words, depending on how you write your C code. Oscar Kilo.
Any NATO translator program you write must have a string array, like the one shown here:
const char *nato[] = { "Alfa", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", "Hotel", "India", "Juliett", "Kilo", "Lima", "Mike", "November", "Oscar", "Papa", "Quebec", "Romeo", "Sierra", "Tango", "Uniform", "Victor", "Whiskey", "Xray", "Yankee", "Zulu" };
The array’s notation, *nato[], implies an array of pointers, which is how the compiler builds this construction in memory. The array’s data type is char, so the pointers reference character arrays—strings—stored in memory. It’s classified as a constant because it’s unwise to create an array of strings as pointers and then risk modifying them later. The nato[] array is filled with the memory locations of the strings, as illustrated in figure 3.1.
For example, in the figure, the string Alfa (terminated with a null character,