I got this error no match for ‘operator=’ (operand types are ‘listNode’ and ‘listNode*’)

I got this error no match for ‘operator=’ (operand types are ‘listNode’ and ‘listNode*’) in code

G->adj[i]=(struct listNode *)malloc(sizeof(struct listNode));

I was representing graph data structure in the adjacency list.

   #include <iostream>

using namespace std;


struct listNode{
    int value;
    struct lsitNode * next;
};

struct Graph{
    int V;
    int E;
    struct listNode *adj;
};

struct Graph * adjListOfGraph(){
    int v,e,i,x,y;
    struct listNode *temp,*t;
    struct Graph *G=(struct Graph *)malloc(sizeof(struct Graph));
    cout<<"Enter total vertices"<<endl;
    cin>>v;
    G->V=v;
    cout<<"Enter total edges"<<endl;
    cin>>e;
    G->E=e;
    G->adj= new struct listNode [(sizeof(int)*(G->V))];
    
    for(i=0;i<G->V;i++){
        G->adj[i]=(struct listNode *)malloc(sizeof(struct listNode));
        G->adj[i]->value=i;
        G->adj[i]->next=G->adj+i;       
    }
    

}
    

Source: Windows Questions C++

LEAVE A COMMENT