Hi all, I am making a program where the user enters a different value for a,b,c and so on. I can make the user cin the alphabet, but when i try to add cout to the for loop, it cannot recognize it. Enough talking, here's the code:
alphabet [26];
for (int i = 0; i < 26; i ++)
cout << alphabet [i];
cin >> alphabet [i];
it says it cannot identify the cin alphabet [i]. But if I take the cout part out
the program works perfect. If I use the cout in another for loop, it just displays the whole alphabet rather than displaying one letter and the user entering a new value for it.
Your alphabet contains only 26 elements (indeces 0 to 25).
When you finish your loop i = 26 so cin >> alphabet [i]; is trying to assign a value to a memory it does not belong to you.
Since I bet you meant differently cin >> alphabet [i]; is not included into for loop.
Probably your desired syntax might be:
1 2 3 4 5
for (int i = 0; i < 26; i ++)
{
cout << alphabet [i];
cin >> alphabet [i];
}