Click here to Skip to main content
15,893,814 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
Generalin Win32 (SDK)color After Printing getting too much li Pin
chachva24-May-05 5:54
chachva24-May-05 5:54 
Generalvariable problem Pin
Anonymous24-May-05 5:50
Anonymous24-May-05 5:50 
GeneralRe: variable problem Pin
jmkhael24-May-05 6:00
jmkhael24-May-05 6:00 
GeneralRe: variable problem Pin
Anonymous24-May-05 6:13
Anonymous24-May-05 6:13 
GeneralRe: variable problem Pin
David Crow24-May-05 6:17
David Crow24-May-05 6:17 
GeneralRe: variable problem Pin
jmkhael24-May-05 6:18
jmkhael24-May-05 6:18 
GeneralRe: variable problem Pin
Anonymous24-May-05 6:24
Anonymous24-May-05 6:24 
GeneralRe: variable problem Pin
Bob Stanneveld24-May-05 7:18
Bob Stanneveld24-May-05 7:18 
Anonymous wrote:
// global variables:
static char boardc[BOARD_SIZE][BOARD_SIZE];
static char turn;
static int kep_row, kep_col;
static int black_eaten, white_eaten;
static int step_num, last_step_num;
static bool remove_dead_chess;
static bool count;
static float black_land, white_land;
static struct step_record step[MAX_STEP+1];


This is wrong!
I believe that you want one variable that is shared among all the components of your application. The current situation is that each object file (component) has its own copy of the variable. So if you execute the following statement in GoApp.cpp:turn = (char)100 the change is only seen in GoApp.cpp, so in GoView.cpp, the variable turn is still undefined!

Try the following instead:
<br />
// Go.cpp<br />
// global variables:<br />
char boardc[BOARD_SIZE][BOARD_SIZE];<br />
char turn;<br />
extern int kep_row, kep_col;<br />
extern int black_eaten, white_eaten;<br />
extern int step_num, last_step_num;<br />
extern bool remove_dead_chess;<br />
extern bool count;<br />
extern float black_land, white_land;<br />
extern struct step_record step[MAX_STEP+1];<br />

<br />
// Go.h<br />
// global variables:<br />
extern char boardc[BOARD_SIZE][BOARD_SIZE];<br />
extern char turn;<br />
int kep_row, kep_col;<br />
int black_eaten, white_eaten;<br />
int step_num, last_step_num;<br />
bool remove_dead_chess;<br />
bool count;<br />
float black_land, white_land;<br />
struct step_record step[MAX_STEP+1];<br />


This way, the value of the variables is the always the same in every component..

Blog[^]
Generalplease help with my attempt to edit subitem of CListCtrl Pin
lucy24-May-05 5:48
lucy24-May-05 5:48 
GeneralRe: please help with my attempt to edit subitem of CListCtrl Pin
lucy24-May-05 9:15
lucy24-May-05 9:15 
GeneralRe: please help with my attempt to edit subitem of CListCtrl Pin
PJ Arends24-May-05 9:26
professionalPJ Arends24-May-05 9:26 
GeneralRe: please help with my attempt to edit subitem of CListCtrl Pin
lucy25-May-05 3:11
lucy25-May-05 3:11 
Generalicons Pin
Dennis L24-May-05 5:42
Dennis L24-May-05 5:42 
GeneralRe: icons Pin
David Crow24-May-05 7:57
David Crow24-May-05 7:57 
GeneralRuntime Error on PCRE library, really need help! Pin
tomfd3s24-May-05 5:07
tomfd3s24-May-05 5:07 
GeneralRe: Runtime Error on PCRE library, really need help! Pin
tomfd3s24-May-05 5:12
tomfd3s24-May-05 5:12 
GeneralRe: Runtime Error on PCRE library, really need help! Pin
jmkhael24-May-05 6:55
jmkhael24-May-05 6:55 
GeneralRe: Runtime Error on PCRE library, really need help! Pin
tomfd3s24-May-05 20:57
tomfd3s24-May-05 20:57 
GeneralMDI Toolbar switch Pin
act_x24-May-05 4:29
act_x24-May-05 4:29 
GeneralRe: MDI Toolbar switch Pin
PJ Arends24-May-05 9:04
professionalPJ Arends24-May-05 9:04 
General_CrtIsValidHeapPointer Pin
Bob Stanneveld24-May-05 4:23
Bob Stanneveld24-May-05 4:23 
GeneralRe: _CrtIsValidHeapPointer Pin
jmkhael24-May-05 6:43
jmkhael24-May-05 6:43 
GeneralRe: _CrtIsValidHeapPointer Pin
Bob Stanneveld25-May-05 21:16
Bob Stanneveld25-May-05 21:16 
GeneralProblem in handling menu :( Pin
nripun24-May-05 4:07
nripun24-May-05 4:07 
QuestionFilmstrip control? Pin
Obliterator24-May-05 2:53
Obliterator24-May-05 2:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.