C

David Arnold dwarnold45 at suddenlink.net
Wed Mar 24 07:36:25 CET 2010


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


More information about the users mailing list