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 543k
  • Answers 543k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

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

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

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

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer UIBezierPath is available in iOS 4.0+. In fact, it was… May 17, 2026 at 6:25 am
  • Editorial Team
    Editorial Team added an answer Each update is stored with a timestamp of when it… May 17, 2026 at 6:25 am
  • Editorial Team
    Editorial Team added an answer Solved when you link the css file just do /path/to_the_file May 17, 2026 at 6:25 am

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 disable PUT, DELETE & TRACE HTTP requests on my Application Server,
I have about 10million values that I need to put in some type of
I need to put an alpha blended gradient border around an image. My problem
I need to put a control to the right of my MenuStrip. The MenuStrip
I need to put an LDAP contextSource into my Java EE container's JNDI tree
Using Redemption I need to put a draft email in a specific Public Folder.
What is the bare minimum I need to put in web.config to get WCF
I have a ListView which sometimes I need to put around 10000 items in.
I'm creating some big files (DB exports) with Java and I need to put

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.