sizeof()'s strange behviour
- From: arnuld <arnVuld@xxxxxxxxxxxxx>
- Date: Tue, 08 Apr 2008 15:58:23 +0500
sizeof() operator gives 2 different types of size outputs :\ but I do not
understand why:
#include <stdio.h>
#include <stdlib.h>
int my_size( char [] );
int main()
{
char s[] = "Saurabh Nirkhey";
printf("sizeof(%s): %d\n", s, sizeof(s));
printf("sizeof(%s): %d\n", s, my_size(s));
return 0;
}
int my_size( char s[] )
{
return sizeof(s);
}
============ OUTPUT =============
/home/arnuld/programs/C $ gcc -ansi -pedantic -Wall -Wextra 5-4.c
/home/arnuld/programs/C $ ./a.out
sizeof(Saurabh Nirkhey): 16
sizeof(Saurabh Nirkhey): 4
/home/arnuld/programs/C $
--http://lispmachine.wordpress.com/
Please remove capital 'V's when you reply to me via e-mail.
.
- Follow-Ups:
- Re: sizeof()'s strange behviour
- From: Richard Heathfield
- Re: sizeof()'s strange behviour
- From: Philip Potter
- Re: sizeof()'s strange behviour
- From: Richard Bos
- Re: sizeof()'s strange behviour
- Prev by Date: Re: sizeof()'s strange behviour
- Next by Date: Re: C90 long long
- Previous by thread: c sharp definition
- Next by thread: Re: sizeof()'s strange behviour
- Index(es):
Relevant Pages
|