Question with function
#5

Quote:
Originally Posted by Raimis_R
Посмотреть сообщение
Its normal because var its global variable and you formating 2texts.
He didn't changed the value of the global variable 'var', he changed the local one 'text'.
Why the global variable has changed?
The reason is because all varialbles which have [](have dimensions) are acting same as pointers. So, you can chage their value via other function if they are in parameters of that function.
Same thing happens in Dev C aswell.

EDIT: It doesn't even need to be global variable if you want to change it. See example below.
pawn Код:
main()
{
     new var[10];
     var="Hey";
     printf("%s",var);// this should print 'Hey'
     Function(var);
     printf("%s",var);// this should print 'Hi'
}
Function(var[])
{
     var="Hello";
}
Reply


Messages In This Thread
Question with function - by BuLLeT[LTU] - 18.07.2011, 17:55
Re: Question with function - by Raimis_R - 18.07.2011, 17:59
Re: Question with function - by swieberdevos - 18.07.2011, 18:01
Re: Question with function - by Jeffry - 18.07.2011, 18:05
Re: Question with function - by Roko_foko - 18.07.2011, 18:10
Re: Question with function - by BuLLeT[LTU] - 18.07.2011, 18:11
Re: Question with function - by BuLLeT[LTU] - 18.07.2011, 18:16

Forum Jump:


Users browsing this thread: 6 Guest(s)