When i try to compile the following code, i get the error
test.c: In function 'main':
test.c:16: error: incompatible types in assignment
and the code is..
#include <stdio.h>
#include <ctype.h>
#include <string.h>
typedef struct {
char name[20];
struct planet* next;
} planet;
int main(int argc, char *argv[])
{
planet *p, *start, *first, *second, *third;
strcpy(start->name, "Suthan");
start->next = *first;
}
1) Allocate some memory to your pointers.
2) You’re setting start->next (a pointer to a planet) to a deferenced pointer
first. That’s the root of your error.3) Move the typedef name to get rid of the warning you were seeing.