|
From: Ramana K. <ra...@my...> - 2002-07-30 07:40:13
|
I have the feeling that I am missing something fundamental in my
understanding of the sizeof operator or multidimensional arrays when I get
these results:
--------snip----------
String Substitutions[][2] = //String is a user-defined class
{
"I'M","I AM",
"YOU'RE","YOU ARE",
"HE'S","HE IS",
"SHE'S","SHE IS",
"IT'S","IT IS",
"WE'RE","WE ARE",
"THEY'RE","THEY ARE"
};
bool SomeFunc(String s)
{
s.Substitute(Substitutions); //pass multidimensional array to member
function
}
--------snip----------
--------snip----------
void String::Substitute(String sub[][2]) //passed Substitutions here
{
String ss[][2] = //exact replica of Substitutions
{
"I'M","I AM",
"YOU'RE","YOU ARE",
"HE'S","HE IS",
"SHE'S","SHE IS",
"IT'S","IT IS",
"WE'RE","WE ARE",
"THEY'RE","THEY ARE"
};
if(sizeof(ss)!=sizeof(sub)) //sizeof identical arrays
{
MessageBox(NULL,"Error","Error",MB_OK);
}
}
--------snip----------
Compiles fine. The MessageBox always appears when running, indicating that
the size of those two identical arrays are different! Obviously something to
do with pointers and passing arrays to functions or something like this is
messing up the operation of the sizeof operator. Anyone have any ideas?
|