Im just learning C++ this year, and its going alright, until i came to arrays that have indexes with semantic content. I am asked to write program that will convert a user inputted string into the civil aviation alphabet, for example if teh user inputted "and" the output would be "Alpha November Delta" with a being alpha, n being november and so on. I want to type out the exact question cuz that would take a long time, and i dont think anyone wants to read it. But so far in my programming i have followed it exactly. My problem comes in the for loop at the end where i must call the appropriate string from my array.
#include <iostream>
#include <string>
#include <cctype>
#include <iomanip>
using namespace std;
enum letters {A, B, C, D, E, F, G, H ,I, J, K, L, M, N, O, P, R, S, T, U, V, W, X, Y, Z};
void string2char(string, char[], int&);
void errorCheck(char[], string&, int&, letters);
void decipher(int, char[], const string[], letters&);
int main()
{
string ICAO[25] = {"Alpha", "Bravo", "Charlie", "Delta", "Foxtrot", "Echo", "Golf", "Hotel", "India", "Juliet", "Kilo", "Lima", "Mike", "November", "Oscar", "Papa", "Romeo", "Sierra", "Tango", "Uniform", "Victor", "Whiskey", "X-Ray", "Yankee", "Zulu"};
letters match; //will be used to match A with
//Alpha, and so on
string input;
int len = 0;
char inputArray[len];
cout << "This program will take an inputted string and\n";
cout << "convert it using the ICAO alphabet.\n";
cout << "Please enter string.\n";
cin >> input;
//call 2 functions, 1st change string to array, 2nd error check
string2char(input, inputArray, len);
errorCheck(inputArray, input, len, match);
decipher(len,inputArray,ICAO,match);
return 0;
}
//i left out the errorchecking and string2char functions
//but ive tested them and they work properly
void decipher(int len, char inputArray[], const string ICAO[], letters& match)
{
int i;
for (i = 0; i < len; i++)
{
//no idea, everything ive tried crashes program, im
//assuming its an out of bounds error
}
return;
}
any help you can give will be greatly appreciated, thanks.