All of lore.kernel.org
 help / color / mirror / Atom feed
From: Krishna Mohan <gkmohan@rocsys.com>
To: Linux c programming list <linux-c-programming@vger.kernel.org>
Subject: scanf with pointers as arguments
Date: 17 Nov 2004 11:20:15 +0530	[thread overview]
Message-ID: <1100670616.1157.15.camel@KrishnaMohan> (raw)

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);




             reply	other threads:[~2004-11-17  5:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-11-17  5:50 Krishna Mohan [this message]
2004-11-17  6:20 ` scanf with pointers as arguments Benjamin Sobotta
2004-11-17  8:56   ` Krishna Mohan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1100670616.1157.15.camel@KrishnaMohan \
    --to=gkmohan@rocsys.com \
    --cc=linux-c-programming@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.