My name is Leon Norwood Jr....hmm..

Anyway I have this program that I'm nearly done with I have to do one of those ICAO(International Civil Aviation Organization program, in fact it's the same program that I did myself several weeks ago, I now have to do it again with arrays and a bit a string.

Once again I have to write a program that takes a string as input and then outputs the corresponding ICAO Alphabet that would be used to spell it out phonetically. I have to rewrite that program using an array of strings to hold the words of the alpha bet, and index the array by the positions of the letters of the alphabet/ i have to make sure to not to index into the array using non alphabetic character that could cause an out of bounds access.

Here's my program here so far....

include <iostream>

include <string>

include <cctype>

using namespace std;

int main()
string inString, Output;
char letter;
int len, index;

string ICAO[26] = {"Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtrot", "Golf", 
                "Hotel", "India", "Juliet", "Kilo", "Lima", "Mike", "November",
                 "Oscar", "Papa", "Quebec", "Romeo", "Sierra", "Tango", "Uniform",
                 "Victor", "Whiskey", "X-ray", "Yankee", "Zulu"};

while(index <= len - 1)

cout << "Please enter a word or string of lower-case letters." << endl;
cin >> inString;
cout <<"You entered," << inString << endl;
cout << "The Phonetic code is: ";
len = inString.length();

index = 0;

letter = inString[index];
letter = tolower(letter);
if(isalpha(letter) = 0)

cout << "Error:" << letter << "is not a letter please enter a word with letters only" << endl;

Output = ICAO[letter - 'a'];

cout << Output << " ";


return 0;


Of course I have an error right that at line 30, non-lvalue in assignment, what does that mean? And what do I do to fix this problem Im almost done.

6 Years
Discussion Span
Last Post by ChrisPadgham

it would help if you indented your code.

lines 6/7 should be below line 15, you can't use the variables until you have assigned them

line 19 is wrong, drop the =0

line 23 should be else {

line 31 probably should be }

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.