All pastes #917328 Raw Edit

Unnamed

public text v1 · immutable
#917328 ·published 2008-02-25 08:33 UTC
rendered paste body
/* 
 * WTF v1.0
 * Author: Joshua K.
 * Date: February 25, 2008
 * Because high school is boring.
 */

#include <stdio.h>
#define _GNU_SOURCE
#include <string.h>

typedef struct phonetic_s {
  char ident[2];
  char name[16];
} phonetic_t;

phonetic_t alnums[] = {
  { "a", "Alpha" },
  { "b", "Bravo" },
  { "c", "Charlie" },
  { "d", "Delta" },
  { "e", "Echo" },
  { "f", "Foxtrot" },
  { "g", "Golf" },
  { "h", "Hotel" },
  { "i", "India" },
  { "j", "Juliet" },
  { "k", "Kilo" },
  { "l", "Lima" },
  { "m", "Mike" },
  { "n", "November" },
  { "o", "Oscar" },
  { "p", "Papa" },
  { "q", "Quebec" },
  { "r", "Romeo" },
  { "s", "Sierra" },
  { "t", "Tango" },
  { "u", "Uniform" },
  { "v", "Victor" },
  { "w", "Whiskey" },
  { "x", "X-ray" },
  { "y", "Yankee" },
  { "z", "Zulu" },
  { "0", "Nada-zero" },
  { "1", "Una-one" },
  { "2", "Bisso-two" },
  { "3", "Terra-three" },
  { "4", "Karte-four" },
  { "5", "Panta-five" },
  { "6", "Soxi-six" },
  { "7", "Sette-seven" },
  { "8", "Okto-eight" },
  { "9", "Nove-nine" }
};
int numalphas = ( sizeof( alnums ) / sizeof( alnums[0] ) );

int main( int argc, char *argv[] ) {
  char output[4096];
  char input[4096];
  int len, num;
  int i,count;

  strcpy( input, argv[1]);
  len = strlen( input );
  printf("%s\n", input );

  for( i = 0; i < len; i++ ) {
    if( isalnum( input[i] ) ) {
      char buf[2];
      sprintf(buf,"%c", input[i] );
      for( num = 0; num < numalphas; num++ ) {
        if( !strcasecmp( buf, alnums[num].ident ) ) {
          strcat( output, alnums[num].name );
          strcat( output, "\n" );
        }
      }
    }
  }

  output[strlen(output)-1] = '\0';
  printf("%s\n", output );
}