Home > Back-end >  C [warning] incompatible pointer type of assignment do not know why
C [warning] incompatible pointer type of assignment do not know why

Time:09-27

#include

#include

#include

Struct answer {

Int number;

Struct anwser * next;

};

Struct answer * first, second, * mid;

Int main () {

Int m, n, q, I, z=1;

The scanf (" % d % d % d ", & amp; N, & amp; M, & amp; Q);

The first=(struct answer *) malloc (sizeof (struct answer));

First - & gt; Number=1;

Mid=first;

for(i=2; i<=q; I++) {

Second=(struct) answer * malloc (sizeof (struct answer));

Second - & gt; Number=I;

Mid - & gt; Next=second; The error I feel ok to c [warning] don't compatible with pointer type assignment

Mid=second;

}
For big solutions

CodePudding user response:

What feeling do not have what problem, with the compiler

CodePudding user response:

Struct answer {

Int number;

Struct r anwse * next;
Note that the scarlet letter

CodePudding user response:

 # include 
#include
#include

Struct answer {

Int number;

//struct anwser * next;
Struct answer * next;

};

Struct answer * first, second, * mid;

Int main () {

Int m, n, q, I, z=1;

The scanf (" % d % d % d ", & amp; N, & amp; M, & amp; Q);

The first=(struct answer *) malloc (sizeof (struct answer));

First - & gt; Number=1;

Mid=first;

for(i=2; i<=q; I++) {

Second=(struct) answer * malloc (sizeof (struct answer));

Second - & gt; Number=I;

Mid - & gt; Next=second;//the error I feel ok to c [warning] don't compatible with pointer type assignment

Mid=second;

}

return 0;
}

For your reference ~

Spelling mistakes ~ another function lack of curly braces
  • Related