Segmentation Fault DEBUG Help

I can't seem to figure out what's the problem when it just says "segmentation fault" as the error when I try to compile my main and .cpp file.

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
  A    [cscreen.cpp] (c)                                                                                            

#include "cscreen.h"
#include <iostream>
#include <unistd.h>
#include <ncurses.h>
#include <stdlib.h>
#include <fstream>

CScreen::CScreen(const char fname[])
{
    ifstream    inFile;
    inFile.open(fname);

    inFile >> m_dispChar;
    inFile >> m_sleep;
    inFile.close();
}




void    CScreen::Scatter()
{
    bool    array2[LINES][COLS];
    int     row;
    int     col;
    int     randLines;
    int     randCols;
    int     counter;

    initscr();

    start_color();
    init_pair(1, COLOR_WHITE, COLOR_BLUE);
    init_pair(2, COLOR_BLACK, COLOR_RED);
    init_pair(3, COLOR_GREEN, COLOR_CYAN);
    init_pair(4, COLOR_BLUE, COLOR_YELLOW);
    init_pair(5, COLOR_RED, COLOR_CYAN);
    attron(COLOR_PAIR(5));
   for(row = 0; row < LINES; ++row)
        {
        for(col = 0; col < COLS; ++col)
            {
            array2[row][col] = true;
            }
        }



    while(true)
        {
        do  {
            randLines = rand() % LINES;
            randCols = rand() % COLS;

            if (counter = LINES * COLS)
                {
                counter = 0;
                }
         }  while (array2[randLines][randCols] != true);

        if (array2[randLines][randCols] == true)
        {
       attron(COLOR_PAIR(counter));

            move(randLines,randCols);
            addch(m_dispChar);
            refresh();
            usleep(m_sleep);
            array2[randLines][randCols] = false;
            ++counter;
             }

            endwin();
        }

}
Due to line 57 (note: = instead of ==) counter will always be 0. You didn't call init_pair(...) for 0.
Topic archived. No new replies allowed.