Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 977481
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T03:54:37+00:00 2026-05-16T03:54:37+00:00

Why do we need to put a & operator in scanf() for storing values

  • 0

Why do we need to put a & operator in scanf() for storing values in an integer array but not while storing a string in a char array?

int a[5];
for(i=0;i<5;i++)
scanf("%d",&a[i]);

but

char s[5]; scanf("%s",s);

We need to pass in the address of the place we store the value, since array is a pointer to first element. So in the case with int/float arrays it basically means (a+i).

But whats the case with strings?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T03:54:38+00:00Added an answer on May 16, 2026 at 3:54 am

    scanf accepts a pointer to whatever you are putting the value in. In the first instance, you are passing a reference to the specific int at position i in your integer array. In the second instance you are passing the entire array in to scanf. In C, arrays and pointers are synonymous and can be used interchangeably (sort of). The variable s is actually a pointer to memory that has contiguous space for 5 characters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 506k
  • Answers 506k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Ah, no, this isn't actually a matter of quoting for… May 16, 2026 at 3:37 pm
  • Editorial Team
    Editorial Team added an answer Too many coders try to limit themselves to the functionality… May 16, 2026 at 3:37 pm
  • Editorial Team
    Editorial Team added an answer Why not just dump it on the document itself? If… May 16, 2026 at 3:37 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Since I need to add an operator& for the std::tr1::array<bool, N> I wrote the
I need to designe predicate for stl algorithms such as find_if, count_if. namespace lib
I was just wondering if there is an XOR logical operator in C (something
I am learning C++ and need some help with compile error messages. I have
following snippet is from rails code def rescue_from(*klasses, &block) options = klasses.extract_options! unless options.has_key?(:with)
I need to get a range (or whole range) of current buffer, run program
Here's my problem. I need to set up a process, preferably with jstl/jsp, that
In Python IDLE Shell it seems I cannot use a compound conditional expression and
I'm trying to create an iterator class as a member-class for a list class,
I have a derived class that's a very thin wrapper around a base class.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.