[scilab-Users] C

Antoine ELIAS antoine.elias at scilab.org
Wed Mar 24 09:11:00 CET 2010


Hi,

I think you should replace %d by %x or %X :

printf("\n\nThe address of var = %x", &var);
printf("\nThe address of var = %X\n", ptr);


Antoine

Le 24/03/2010 07:36, David Arnold a écrit :
> All,
>
> I'm trying to remember a little C so that I can work on the interface section in Modeling and Simulation by Campbell, et al. However, I am stuck:
>
> #include<stdio.h>
>
> int var=1;
> int *ptr;
>
> main() {
> 	
> 	ptr=&var;
> 	
> 	printf("\nDirect access, var = %d", var);
> 	printf("\nIndirect access, var = %d", *ptr);
> 	
> 	printf("\n\nThe address of var = %d",&var);
> 	printf("\nThe address of var = %d\n", ptr);
> 	
> 	return 0;
> 	
> }
>
> On my macbook pro (10.6.2), I get this error:
>
> david-arnolds-macbook-pro-2:cprograms darnold$ gcc hello.c
> hello.c: In function ‘main’:
> hello.c:13: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘int *’
> hello.c:14: warning: format ‘%d’ expects type ‘int’, but argument 2 has type ‘int *’
>
>
> What am I doing wrong?
>
> David


-- 
Antoine ELIAS
Software developer
-------------------------
The Scilab Consortium
Digiteo
Domaine de Voluceau
Rocquencourt - B.P. 105
78153 Le Chesnay France
Phone: +33.1.39.63.50.63




More information about the users mailing list