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

  • SEARCH
  • Home
  • 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 8663703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:03:07+00:00 2026-06-12T17:03:07+00:00

int age; char name[10]; scanf(%d, &age); scanf(%s, name); In first scanf function we use

  • 0
int age;
char name[10];

scanf("%d", &age);
scanf("%s", name);

In first scanf function we use '&' symbol before age, but in second scanf we don’t use '&'
as it is a char array. Can anybody tell me why is so?

  • 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-06-12T17:03:08+00:00Added an answer on June 12, 2026 at 5:03 pm

    Under most circumstances, an expression of type “N-element array of T” will be converted to (“decay”) to type “pointer to T“, and the value of the expression will be the address of the first element in the array.

    When you write

    scanf("%s", name);
    

    the expression name has type “10-element array of char“; by the rule above, it is converted to type “pointer to char“, and its value is the same as &name[0]. So scanf receives a pointer value, not an array value.

    The exceptions to this rule are when the array expression is an operand of the sizeof, _Alignof, or unary & operators, or is a string literal being used to initialize another array in a declaration.

    Note that the expressions name and &name will give you the same value (the address of the first element of the array is the same as the address of the array), but their types will be different; name will have type char *, while &name will have type char(*)[10], or “pointer to 10-element array of char“.

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

Sidebar

Related Questions

I have a structure typedef struct store { char name[11]; int age; } store;
#include <stdio.h> main() { typedef struct{ char *name; int age; }person[5]; int i; for
struct person { int age; char name[100]; struct person *next; }; void delfirst(struct person
I have class Person as following : class Person { char* name; int age;
Say I have a structure: struct person { char name[10]; int age; }; struct
struct node { char name[20]; int age; int height; node* next; // Pointer to
typedef struct employee { int age; char name[30]; } emp_t; emp_t * e; int
Let's say you have- struct Person { char *name; int age; int height; int
#include <iostream> using namespace std; struct list { char name[20]; int age; double height;
I have a data structure Person struct Person { protected: string name; int age;

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.