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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:30:44+00:00 2026-06-06T15:30:44+00:00

My assignment is to create a simple graph that has both Nodes and Edges.

  • 0

My assignment is to create a simple graph that has both Nodes and Edges.
In my header file which was given and cant’t be modified I have

typedef struct Edge_s* Edge;
typedef struct Node_s* Node;
typedef struct Graph_s* Graph;

and in my graph.c

typedef struct{
  size_t w;
  struct Node_s* target;
}*Edge;

typedef struct{
  size_t value;
  Edge* edges;
  size_t s;
}*Node;

typedef struct{
  Node* nodes;
  size_t n;
  Edge* edges;
  size_t e;
}*Graph;

Edge create_edge(Node t, size_t w){
  Edge ret = malloc(sizeof(*ret));
  ret->target = t;
  ret->w = w;
  return ret;
}

This gives a warning on compile

warning: assignment from incompatible pointer type

I’m kind of confused here, what am I getting wrong and how should I fix it? The program is almost working and I’m getting one strange bug that I believe might be because of this.

  • 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-06T15:30:46+00:00Added an answer on June 6, 2026 at 3:30 pm

    Your typedef-definitions are mixed up badly. I’m surprised it even compiles.

    You first defined typedef-name Edge as

    typedef struct Edge_s* Edge;
    

    and then later re-defined it as

    typedef struct{
      size_t w;
      struct Node_s* target;
    }*Edge;
    

    These two definitions define Edge in two completely unrelated ways. (All C compilers I know would immediately report an error if the first group of declarations would meet the the second group in the same translation unit.)

    I’d say that your second struct definition should be simply

    struct Edge_s {
      size_t w;
      struct Node_s* target;
    };
    

    Don’t attempt to redefine an existing typedef-name. It is simply illegal in C.

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

Sidebar

Related Questions

I'm implementing a simple game for an assignment that would ideally run both on
I have a Header at the top of 3 lists, which contains simple Create
I'm using super-simple synchronous C# Sockets for an assignment. The assignment is to create
So basically the assignment was we had to create a doubly linked list that's
For a school assignment I have to create a C++ program that will create
As a school assignment, I am supposed to create a program in C# that
I have a moderately simple assignment, to create a PHP/PDO site with login functionality
I have created a simple class called Engine which has an ivar called inputName
In Python, I have a Graph class that has a dictionary of vertex objects.
For a school assignment, I am trying to create a simple HTTP server using

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.