R
ranjeet.gupta
Dear All
I am not able o understand the exact number of bytes allocation done
by the two fucntion given below, It is said that the fuction
Condition_String1 allocates the 240 bytes while
Condition_String2 allocates the 72 bytes,
I am not able to get the Artimatic Numbers to staisfy the above
Number of bytes allocated,
What I think Is that The First fuction Condition_String1 allocates
(4 bytes (Case is the Int)) * (15 Cases) * 2 (bytes char)) = 120
but how it is 240 ??
For Fuction Condition_String2 = 45 bytes
Please let me know where I am wrong
FUNCTION 1:
char * Condition_String1(int condition) {
switch(condition) {
case 0: return "EQ";
case 1: return "NE";
case 2: return "CS";
case 3: return "CC";
case 4: return "MI";
case 5: return "PL";
case 6: return "VS";
case 7: return "VC";
case 8: return "HI";
case 9: return "LS";
case 10: return "GE";
case 11: return "LT";
case 12: return "GT";
case 13: return "LE";
case 14: return "";
default: return 0;
}
}
FUNCTION 2:
char * Condition_String2(int condition) {
if ((unsigned) condition >= 15) return 0;
return
"EQ\0NE\0CS\0CC\0MI\0PL\0VS\0VC\0HI\0LS\0GE\0LT\0GT\0LE\0\0"
+
3 * condition;
}
Thanks In advance
Ranjeet
I am not able o understand the exact number of bytes allocation done
by the two fucntion given below, It is said that the fuction
Condition_String1 allocates the 240 bytes while
Condition_String2 allocates the 72 bytes,
I am not able to get the Artimatic Numbers to staisfy the above
Number of bytes allocated,
What I think Is that The First fuction Condition_String1 allocates
(4 bytes (Case is the Int)) * (15 Cases) * 2 (bytes char)) = 120
but how it is 240 ??
For Fuction Condition_String2 = 45 bytes
Please let me know where I am wrong
FUNCTION 1:
char * Condition_String1(int condition) {
switch(condition) {
case 0: return "EQ";
case 1: return "NE";
case 2: return "CS";
case 3: return "CC";
case 4: return "MI";
case 5: return "PL";
case 6: return "VS";
case 7: return "VC";
case 8: return "HI";
case 9: return "LS";
case 10: return "GE";
case 11: return "LT";
case 12: return "GT";
case 13: return "LE";
case 14: return "";
default: return 0;
}
}
FUNCTION 2:
char * Condition_String2(int condition) {
if ((unsigned) condition >= 15) return 0;
return
"EQ\0NE\0CS\0CC\0MI\0PL\0VS\0VC\0HI\0LS\0GE\0LT\0GT\0LE\0\0"
+
3 * condition;
}
Thanks In advance
Ranjeet