Help with project please

These are the instructions for my project
Write a C++ program that inputs a string and output a series of ICAO words that would be used to spell it out. For example:

Enter string: Program Test.
Phonetic version is: Papa Romeo Oscar Golf Romeo Alpha Mike Tango Echo Sierra Tango

Note that there is a space in the string being translated and letters can be entered either upper or lower case. Any characters other than alphabet or the space should be ignored.

You should create a function called BuildCodeArray to build an array of strings of the ICAO words.

You should create a second function called TranslateString that takes a string and translates it into the ICAO spelling.

After printing the ICAO words the application should ask the user if they want to translate another string and continue looping until the user indicates they do not want to translate another string.

This is what I have so far. I'm stuck please help
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
	

#include <iostream>
#include <string>
using namespace std;


void TranslateString(string input, string *ICAO, char letter, string output);
void BuildCodeArray();
	

int main() 
{
	string input;
	string output;
	char letter;

	string ICAO[26];

	cout << "Please enter what you want tranaslated to ICAO:" << endl;
		cin >> input;


	
			cout << "Your translated string is: " << TranslateString << endl; 
		

	system("pause");
}

void BuildCodeArray()
{
	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"
	};
}

void TranslateString(string input, string ICAO[], char letter, string output)
{
	
	
	for(unsigned int i = 0; i < input.size(); i++)
	{
		letter = input[i];
			if(!isalpha(letter)) { ++i; continue;}
		letter = toupper(letter);
		output = ICAO[letter - 'A'];
		 
		cout << output;
		
		
		/*std::string output;
		string letter = ICAO[i];
		input = toupper(input);

		output = ICAO[letter - 'A'];
		cout << output << endl;	*/
	}

}
A few - but maybe not all issues:
* You need to use getline to read a string since it can contain spaces.
* You need to pass an array to your BuildCodeArray function. Currently you create a local array that
can't accessed anywhere.
* In main you have to pass the parameters to your TranslateString function.
* In TranslateString out must be a reference.
Topic archived. No new replies allowed.