foo(char *s){
printf("%d", sizeof(s)); // correction
}
in this function foo s is a pointer so it print size of pointer which is 4 .
On Sat, Sep 3, 2011 at 6:22 PM, priya ramesh <[email protected]
> wrote:
> In any C program,
> int main(){
> char a[100];
> foo(a);
> printf("%d", sizeof(a));
> }
> foo(char *s){
> printf("%d", sizeof(a));
> }
>
> In main sizeof a is 100, in foo it is 4. why??
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.