PREV INDEX NEXT

Author: Stan Eisenstat
Subject: Re: [Cs223] -t flag
Date: Wednesday, 29 Apr 2020, 11:23:25


    > Message Posted By: Unknown
    ...
    > I am trying to implement the -t flag with an global array, to keep track
    > of whether I have visited a tile before, and if I did, then don't go into
    > the if loop.
    >
    > Right now I have a int* track (set as global variable), calloced in main
    > function according to the size of the board, and use it in traverse
    > function. However, I keep having valgrind errors saying that reading track
    > or writing to track is invalid.
    >
    > Is it okay to have a global array whose space is malloced in main? Does
    > this approach sound right?

I cannot diagnose your valgrind error without being
able to see and run your code.

Yes, you may use global variables.

Yes, an approach along the lines you describe can
work.

--Stan-
PREV INDEX NEXT