linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* scanf with pointers as arguments
@ 2004-11-17  5:50 Krishna Mohan
  2004-11-17  6:20 ` Benjamin Sobotta
  0 siblings, 1 reply; 3+ messages in thread
From: Krishna Mohan @ 2004-11-17  5:50 UTC (permalink / raw)
  To: Linux c programming list

Hi
Can anybody plz tell me what's wrong with this code!
I am getting SEGMENTATION FAULT. ofcourse, if i use &i, &s as arguments
in scanf, it's work fine as usual. can't i use pointers which hold the
address of i and s. plz clarify this. THANKS IN ADVANCE.

	int i,*iptr = &i;
        short s,*shptr = &s;
        printf("enter 2 values:\n");
        scanf("%d %d",iptr,shptr);
        printf("%d %d\n",*iptr,*shptr);
	printf("%d %d\n",i,s);




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2004-11-17  8:56 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-11-17  5:50 scanf with pointers as arguments Krishna Mohan
2004-11-17  6:20 ` Benjamin Sobotta
2004-11-17  8:56   ` Krishna Mohan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).