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)
{
                   break;
}

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

Output = ICAO[letter - 'a'];

cout << Output << " ";
index++;

cin.get();
cin.get();

system("pause");
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.

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 }

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.