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 8936455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:12:57+00:00 2026-06-15T10:12:57+00:00

This is the def of my structure typedef struct treeNode { int data,pos; char

  • 0

This is the def of my structure

    typedef struct treeNode
     {
        int data,pos;
        char name[16];
        struct treeNode *left;
        struct treeNode *right;
     }treeNode;

I have created an dynamic object

treeNode *temp;
            temp = (treeNode *)malloc(sizeof(treeNode));

If I have to assign a value to data how should I assign

scanf("%d",temp->data);   //or
scanf("%d",&(temp->data)); //why? because all scanf will look for is address to a location which could be done by temp->data;

and this goes for accessing data also i.e. how should I access the integer part ?

temp->data; //or
*(temp->data) 
  • 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-15T10:12:59+00:00Added an answer on June 15, 2026 at 10:12 am

    scanf("%d",&temp->data);

    Because scanf() needs address of variable. For each conversion specifier, scanf() expects the corresponding argument to be a pointer to the proper type: %d expects an argument of type int *, %f expects an argument of type double *, %c and %s both expect an argument of type char *, etc.

    Behaviour of scanf() gives more idea about scanf().

    for accessing temp->data is enough, because it is essentially equivalent to (*temp).data.

    If you try to access *(temp->data) then you trigger undefined behaviour. Because, you are accessing a memory location which may be in other process’s context.

    say temp->data is 100, then *(temp->data) means *(100), i.e accessing at memory location 100.

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

Sidebar

Related Questions

I have directory structure like this data |___ | abc |____incoming def |____incoming |____processed
The typical Python threadpool will have a structure like this one: def run(self): while
I have the following structure: class foo(object): class bar(object): def __init__(self, parent): self._parent=parent #this
I have a simple structure like this: (def example {:bbb bbb :xxx [1 2
I have a sequence with a structure like this: (def date-sequence [[20101121 10] [20101120
I have a directory structure like this: root folder1 abc.json def.json somedir more.json folder2
I hava a data structure that looks like this: (def conf { :devices [{:alias
Suppose I have a nested structure, something like this: {:data1 {:categories [ {:name abc
I have an xml structure like this <JJJ version=2.0 > <Data > <Object class=classX>
I have a definition like this def bar(self, foo=None, bar=None, baz=None): pass I want

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.