counter controlled for loop issue

I'm trying to design a piece of code to create a pattern, however I can't get my compiler, Xcode, to recognize the counter variable. Any solutions? Also I don't know if my loop will make the patter but that's not my immediate concern. Code as follows:

#include <iostream>
#include <iomanip>

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
using namespace std;

int rowSize, lineNum , spaceNum;

void pattern1(char a)
{
    do
    {
        cout << "\n\nPlease choose the size of the pattern: (3), (4), (5), (6)\n\n";
        cin >> rowSize;
        
        if(!cin)
        {
            cout << "\n\nThat was not a whole number. Please try again.";
            cin.clear();
            cin.ignore(1000,'\n');
        }
        
        if (!(rowSize == 3 || rowSize == 4 || rowSize == 5 || rowSize == 6)) 
        {
            cout << "\n\nThat was not a whole number. Please try again.";
        }
        
        if (cin && (rowSize == 3 || rowSize == 4 || rowSize == 5 || rowSize == 6))
        {
            loop = true;
        }
    }
    
    while (loop == false);
    
        cout << "\n\nHere is the pattern you've selected:\n\n";
    
    for (int counter = 0; counter <= rowSize; counter++)
    {
        cout << setw(rowSize) << left << setfill('#');
        
        for (lineNum = '1'; lineNum <= rowSize ; lineNum++)
        {
            for (spaceNum = '1'; spaceNum <= lineNum ; spaceNum++)
            {
                while (spaceNum == lineNum)
                    cout << rowSize;
                while (spaceNum != lineNum)
                    cout << "";
            }
        }
        
    }

    
    
}

In lines 38 and 40 I don't believe '1' is what you want.

1
2
3
4
5
6
#include <iostream>

int main()
{
    std::cout << static_cast<int>('1') ;
}
49


1 without the single quotes, maybe.
Topic archived. No new replies allowed.