Char Array Upside-down Question-mark Error

I am trying to create a partially filled array of characters and a function that would delete any characters in the array that are repeated. I have not got to the second part yet, because when I try to display the partially filled character array, I get upside down question marks for output. Any suggestions?


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
  #include <iostream>
using namespace std;
int main()
{
    char foo[10], i, input, x;
    for(i = 0; i < 10; i++)
    {
        cin >> input;
        if (input != 'z')
            foo[i] = input;
        else
            break;
    }
    for (x = 0; x < i; x++)
        cout << foo[i] << "\t";
    
    return 0;
}
In the second for loop, you should try printing foo[x] instead of foo[i] ;)
Topic archived. No new replies allowed.