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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:47:06+00:00 2026-06-01T03:47:06+00:00

Sorry if the title is a little confusing. What I’m doing is creating a

  • 0

Sorry if the title is a little confusing. What I’m doing is creating a structure such as:

struct record
{
    int value;
    int key;
};

Then using a typedef to call a pointer to record “Item” like this:

typedef struct record* Item;

Basically I’m following how it was done in Algoriths in C by Robert Sedgewick (third edition) on page 290 in case anyone happens to have this book.

What I’m having trouble with is reading in a value from the console, then assigning that to the key. Here’s what I have, and the errors that I’m getting:

void setKey(Item *element, int x)
{
    element->key = x;
}

void standInput(Item A[], int length)
{
    int i;
    int x;
    for(i = 0; i < length; i++)
    {
        printf("Enter a value for spot %i: ", i+1);
        scanf("%d", &x);
        setKey(A[i], x);
    }
}

gcc Item.h
Item.h:33:6: warning: conflicting types for ‘setKey’
Item.h:23:3: note: previous implicit declaration of ‘setKey’ was here

If I could get a nudge in the right direction, I’d really appreciate it. I got the program for this assignment working perfectly when Item was just simple ints, but now I’m trying to use Item->Key and I’m a little lost 🙂 Thanks!

If anyone needs any other portion of the code that I didn’t think necessary, I’ll post it as soon as I see the request.

Revision: I moved my setKey function above standInput, so the compilation error has gone away. What I am getting though is a segment fault, so I’m still assigning it wrong 🙂

  • 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-01T03:47:07+00:00Added an answer on June 1, 2026 at 3:47 am

    The type of setKey‘s first argument should be Item, not Item *, since the Item type already is a pointer. You want to pass a pointer to a record, not a pointer to a pointer to a record.

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

Sidebar

Related Questions

Sorry if the title is a little confusing. Here's what I meant - I
I'm sorry for the little confusing title but say I have a class with
Sorry if the post title wasn't clear, I will try to explain a little
I'm sorry if my title is a little unclear. Basically I want to print
Sorry for the bad title but it's a little complicated to get across in
Sorry if the title is confusing In Eclipse Aptana PHP Editor, if I insert
Sorry if the title is a little vague, I do not know how else
sorry if the title is a little.. vague i couldnt pin it down. So
Sorry if the title of the question is a little misleading but I was
Sorry about the poor title, it will be a little easier to describe what

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.