[Subject Prev][Subject Next][Thread Prev][Thread Next][Subject Index][Thread Index]
Re: C Program
Wow!...this is interesting. Here is a gdb session on the file..
(gdb) break 10
Breakpoint 1 at 0x80483df: file tt.c, line 10.
(gdb) r
Starting program: /home10/sojan/./a.out
Breakpoint 1, main () at tt.c:10
10 printf("\n%x",add);
(gdb) p add
$1 = {int (int, int)} 0x80483c8 <add>
(gdb) p *add
$2 = {int (int, int)} 0x80483c8 <add>
(gdb) p *(*add)
$3 = {int (int, int)} 0x80483c8 <add>
(gdb) p add(2,3)
I am there
$4 = 14
(gdb)
Is this in some way related to the fact that we need not dereference a
pointer to a function to call it?....but it still doesn't make sense, does
it?
On Thu, 12 Oct 2000, Rajani K wrote:
> Hi All!!
>
> heres a piece of C code,
>
> #include<stdio.h>
>
> int add(int a, int b)
> {
> printf ( "\n I am there \n" );
> }
>
> main()
> {
> printf("\n%x",add);
> printf("\n%x",*add);
> printf("\n%x",*(*(*(*add))));
> }
>
> The Compiler does not crib. The program gets built and
> the result prints the same value for all the above three printfs.
> What can be the probable reason ?
>
> TIA!!
>
> Cheers
> Rajani
>
>
> ---------------------------------------------
> LIP is all for free speech. But it was created
> for a purpose. Violations of the rules of
> this list will result in stern action.
>
--
Sojan James
Consultant, National Semi. India Designs Ltd.
7/6 Brunton Road, Bangalore 560025. India.
Ph: 5587918/919/920 ext. 308