A
Active8
Hi:
This prob "magically" stopped and I'm not sure if I can recreate it,
but thought I'd share it and maybe learn something.
#include "stdafx.h"
#include <stdlib.h>
#include <math.h>
#include <fstream.h> //iostream.h
// yes, I'll fix those includes, too
class Yi
{
public:
Yi();
int Number(char bits){return _myNumber[bits];
}
private:
int _myNumber[64];
int _myReverse[64];
//int place1; // prevents array element corruption.
char _myShortName[64][32];
char _myName[64][64];
};
#include <iostream.h>
#include <string.h>
#include "yi.structure.h"
// ditto with those includes
Yi::Yi()
{
int num[64] = {2,23,8,20,16,35,45,12,
15,52,39,53,62,56,31,33,
7,4,29,59,40,64,47,6,
46,18,48,57,32,50,28,44,
24,27,3,42,51,21,17,25,
36,22,63,37,55,30,49,13,
19,41,60,61,54,38,58,10,
11,26,5,9,34,14,43,1};
char short_name[64][32] = {"Creative","Receptive",
// blah blah
char name[64][64] = {"The Creative","The Receptive",
// more blah
for(int i=0;i<64;i++)
{
_myNumber = num;
_myReverse[ num ] = i;
strcpy(_myName,name);
strcpy(_myShortName,short_name);
}
}
See that odd comment
//int place1; // prevents array element corruption.
?
That's what I had to do to make it work. What would happen was I'd
instanciate a Yi and look up the number of a symbol using
int Number(char bits){return _myNumber[bits];
based on 6 bits (char bits, would you guess?) which represent the
symbol.
Number() always returned 21 - saw it in the debugger. I get lost when
the debugger steps into the library code and couldn't figure out
exactly where the problem was, just that the return value of Number()
was always 21.
//int place1; // prevents array element corruption.
was the fix except at the time int _myReverse[64]; wasn't needed and
I wouldnt be surprised if int _myReverse[64]; is what's keeping things
working today.
Structure member alignment has always been set at 8 bytes FWIW
I thought the array was corrupted because of the fix, but am not sure
if I checked the whole array at the time. maybe it wassomething else.
Mike
This prob "magically" stopped and I'm not sure if I can recreate it,
but thought I'd share it and maybe learn something.
#include "stdafx.h"
#include <stdlib.h>
#include <math.h>
#include <fstream.h> //iostream.h
// yes, I'll fix those includes, too
class Yi
{
public:
Yi();
int Number(char bits){return _myNumber[bits];
}
private:
int _myNumber[64];
int _myReverse[64];
//int place1; // prevents array element corruption.
char _myShortName[64][32];
char _myName[64][64];
};
#include <iostream.h>
#include <string.h>
#include "yi.structure.h"
// ditto with those includes
Yi::Yi()
{
int num[64] = {2,23,8,20,16,35,45,12,
15,52,39,53,62,56,31,33,
7,4,29,59,40,64,47,6,
46,18,48,57,32,50,28,44,
24,27,3,42,51,21,17,25,
36,22,63,37,55,30,49,13,
19,41,60,61,54,38,58,10,
11,26,5,9,34,14,43,1};
char short_name[64][32] = {"Creative","Receptive",
// blah blah
char name[64][64] = {"The Creative","The Receptive",
// more blah
for(int i=0;i<64;i++)
{
_myNumber = num;
_myReverse[ num ] = i;
strcpy(_myName,name);
strcpy(_myShortName,short_name);
}
}
See that odd comment
//int place1; // prevents array element corruption.
?
That's what I had to do to make it work. What would happen was I'd
instanciate a Yi and look up the number of a symbol using
int Number(char bits){return _myNumber[bits];
based on 6 bits (char bits, would you guess?) which represent the
symbol.
Number() always returned 21 - saw it in the debugger. I get lost when
the debugger steps into the library code and couldn't figure out
exactly where the problem was, just that the return value of Number()
was always 21.
//int place1; // prevents array element corruption.
was the fix except at the time int _myReverse[64]; wasn't needed and
I wouldnt be surprised if int _myReverse[64]; is what's keeping things
working today.
Structure member alignment has always been set at 8 bytes FWIW
I thought the array was corrupted because of the fix, but am not sure
if I checked the whole array at the time. maybe it wassomething else.
Mike