I'm making a utility for my school to generate a script for out teleprompter. I need to change a variable inside a loop (I will highlight the variable). Heres the code:
Still working on it. If I left something out tell me. the variable is bolded and underlined in line 51. I need to change it from anc1 to anc2 - anc10 after each loop. The int Loop is the number of times it should loop. int TimesLooped is the amount of times the loop has repeated.
you could use an array for each of the ten strings. This would look something like this:
1 2 3 4 5 6 7 8 9 10 11 12
// At the top, instead of anc1,...,anc10:
string anc[10];
// ...
// The loop:
int index = 0;
while (Loop != TimesLooped) {
cout << "Type an announcement";
getline(cin, anc[index]);
index++;
}
This works of course for maximal 10 strings. You can also achieve having an (almost) arbitrary number of strings by dynamically allocating the array anc.
I can't reproduce this error here, the program compiles and runs. I assume that there is a variable index already declared in iostream, so maybe changing the name of index to something else does the trick.
ok I changed index to index2 and it cleared up all of the issues except
1 2 3 4
while (Loop != TimesLooped) {
cout << "Type an announcement";
getline(cin, anc[index2]);
index++; //ISO C++ forbids incrementing a pointer of type 'char* (*)(const char*, int)' (2)
im going to compile it in dev c++ not xcode and try it