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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T19:13:46+00:00 2026-06-13T19:13:46+00:00

Possible Duplicate: Assignment from incompatible pointer type warning I have two structures, one which

  • 0

Possible Duplicate:
“Assignment from incompatible pointer type” warning

I have two structures, one which builds off the other. My hope is to use them together to create an adjacency list for a directed weighted graph.

Here are my structures:

typedef struct{
        int v;
        int edgeWeight;
        struct adjEdge * next;
}adjEdge;

typedef struct{
        int v;
        int weight;
        struct  adjEdge *adj;
}vertex;

So basically the vertex adj will be null unless there is a connection to another vertex, which is the adjEdge structures function.

My issue is that when I assign a adjEdge to the vertex structure I am getting an error:

bfs.c:75: warning: assignment from incompatible pointer type 

Here is part of the code. Look to it to see where the errors are actually being thrown

while((fscanf(fp, "%d %d %d", &u, &v, &w)) != EOF)
{
    vertexArray[u-1].v = u;


    adjEdge * newEdge;
    newEdge->v = v;
    newEdge->edgeWeight = w;
    newEdge->next = NULL;

    if(vertexArray[u-1].adj = NULL)
    {
        vertexArray[u-1].adj = newEdge; //error
    }
    else
    {
        adjEdge * traverse = vertexArray[u-1].adj; //error
        while(traverse->next != NULL)
        {
            traverse = traverse->next; //error
        }
        traverse->next = newEdge;  //error
    }
}

I thought once declared in my structures I could utilize assignments like 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-13T19:13:47+00:00Added an answer on June 13, 2026 at 7:13 pm

    The problem is in the way you have defined structures. Define them as follows and get rid of the warnings.

    typedef struct adjEdge_{
            int v;
            int edgeWeight;
            struct adjEdge_ * next;
    }adjEdge;
    
    typedef struct vertex_{
            int v;
            int weight;
            struct  adjEdge_ *adj;
    }vertex;
    

    Hope this helps!

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

Sidebar

Related Questions

Possible Duplicate: Tuple parameter declaration and assignment oddity In Scala, one can do multiple-variable
Possible Duplicate: Is array name a pointer in C? Array Type - Rules for
Possible Duplicate: Java Generics, how to avoid unchecked assignment warning when using class hierarchy?
Possible Duplicate: NAnt or MSBuild, which one to choose and when? What is the
Possible Duplicate: Why use two stacks to make a queue? I got this assignment
Possible Duplicate: Python urllib2 Progress Hook I have a script which uploads a file
Possible Duplicate: Assignment Condition in Python While Loop What's the equivalent of this: while
Possible Duplicate: Ruby Assignment Syntax I don't get the concept of an assignment method
Possible Duplicate: How do I do multiple assignment in MATLAB? When dealing with cell
Possible Duplicate: How do I do multiple assignment in MATLAB? So let's say I

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.