The code goes fine for one case, goes mad in the second

So, i made this program that uses a few lines and spaces to create a sort-of bounce like line on the console. Tough it only uses / and \ so i added the option for the user to modify the chars it uses to make lines. But, whenever the user activates the option (by setting folsopts to true) and modifies the chars held in cara, the program stops creating spirals, and instead goes into a weird madness.
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
 #include <iostream>
#include <windows.h>
#include <cstdlib>
#include <ctime>
#include <cstring>
using namespace std;









/**
Variabilele de sistem
*/
int factor=1;
int speed=30;
int lungimea=118;/// Defaullt 108 sau 79 MAX 108 or 118
int folsopts=1; ///Folositi caracterele de mai jos
const char cara[2] = { '|', '|' };
/**
Modificati in voie
*/

void scps(int i)
{
    int o=0;
    while(o<i)
    {
        cout<<" ";
        o++;
    }
}
void show1()
{
    int i=lungimea;
    while(i>0)
    {
        scps(i);
        if(folsopts==0)
        {
            cout<<'/'<<endl;
        }
       if(folsopts==1)
       {
            cout<<cara[0];
       }
        Sleep(speed);
        i-=factor;
    }
}
void show2()
{
    int i=0;
    while(i<lungimea)
    {
        scps(i);
        if(folsopts==0)
        {
            cout<<'\\'<<endl;
        }
        if(folsopts==1)
        {
            cout<<cara[1];
        }
        Sleep(speed);
        i+=factor;
    }
}
int main()
{
    cout<<"Lenght: ";
    cin>>lungimea;
    cout<<"Factor (how abrupt the diagonal is): "<<endl;
    cin>>factor;
    cout<<"Speed (higher -> slower)"<<endl;
    cin>>speed;
    int var=1;
    while(2)
    {
        switch(var)
        {
        case 1:
        {
            var=0;
            show1();
            break;
        }
        case 0:

        {
            var=1;
            show2();
        }

        }

    }
    return 0;
}
nvm. I realised i had to add <<endl; after couting cara. Sorry for wasting your time.
Topic archived. No new replies allowed.