Question on function parameters: formals and actuals

 

i already test so kinda know but i want this 100% clear in head by others replies. thank you

.

my reason is simple, i alter formal declaration from string to int.

of course :), i not bother to deal with many files etc. in mirroring this formal parameter change.

>>>maybe i assume compiler pickup callers using string actual instead of int data...

>>>so i think i assume wrong, this is wat want confirmed.

thank you

.

i only 'discover' when code testing, start get weird errorhandler o/p (good to get, but scary cuz not 'get it', variable values not make sense...)

.

Editor help snippet:

Arguments (formal parameters) are passed by value, i.e., each expression xl, . . ., xn is calculated, and the value is passed to the function. The order of expressions calculation and that of values loading are guaranteed. During the execution, the system checks the number and type of arguments given to the function.

.

am i correct that if actual param is type string and formal param is type int that due to Type Casting and above rule, the function actually gets the numeric value contained in actual param.

eg,

int a(int i) //formal

a("abc"); //actual

so, numeric value of "abc" is wat a() sees.

 

My test says:

int start(){
 string x;
 x = "";
 Print("x = ", x, "  a(x) = ",a(x));
  x = "a";
 Print("x = ", x, "  a(x) = ",a(x));
  x = "ab";
 Print("x = ", x, "  a(x) = ",a(x));
  x = "abc";
 Print("x = ", x, "  a(x) = ",a(x));
  x = "abcd";
 Print("x = ", x, "  a(x) = ",a(x));
  x = "abcde";
 Print("x = ", x, "  a(x) = ",a(x));
  x = "abcdef";
 Print("x = ", x, "  a(x) = ",a(x));
  x = "abcdefg";
 Print("x = ", x, "  a(x) = ",a(x));
  x = "abcdefgh";
 Print("x = ", x, "  a(x) = ",a(x));
  x = "abcdefghi";
 Print("x = ", x, "  a(x) = ",a(x));
}
 int a(int y){
  return(y);
 }
2008.10.29 22:40:34 Phy__Test GBPJPY,Daily: x = abcdefghi  a(x) = 0
2008.10.29 22:40:34 Phy__Test GBPJPY,Daily: x = abcdefgh  a(x) = 0
2008.10.29 22:40:34 Phy__Test GBPJPY,Daily: x = abcdefg  a(x) = 0
2008.10.29 22:40:34 Phy__Test GBPJPY,Daily: x = abcdef  a(x) = 0
2008.10.29 22:40:34 Phy__Test GBPJPY,Daily: x = abcde  a(x) = 0
2008.10.29 22:40:34 Phy__Test GBPJPY,Daily: x = abcd  a(x) = 0
2008.10.29 22:40:34 Phy__Test GBPJPY,Daily: x = abc  a(x) = 0
2008.10.29 22:40:34 Phy__Test GBPJPY,Daily: x = ab  a(x) = 0
2008.10.29 22:40:34 Phy__Test GBPJPY,Daily: x = a  a(x) = 0
2008.10.29 22:40:34 Phy__Test GBPJPY,Daily: x =   a(x) = 0
2008.10.29 22:40:34 Phy__Test GBPJPY,Daily: loaded successfully
 

ok, ur time taken to test is much liked, thankyou

i run code to - results as 'expected' sob, sob

so i now go back to paper + pencil = slowButSure cuz must be zillions errorhandler calls made

oh yes, i open PSPad and use superior search/replace + regular expressions

hahaaaa - wonder if '5' ME have more flexi abilities???

thankyou again, yes is good you reply - was dumb think on my part - straw grasping i was - lol

:o)

 

Very first value I saw beginning test was something like -1792738473 for "abc" but not seen again.

I get confused sometimes, too.