I'm getting an error about the assignment of a value to my data type below, any suggestions would be helpful.
Code:
typedef struct node{ char data[100]; struct node *next; } Node;
typedef struct list{ Node *head; Node *tail; int size;} LL;
// initializer for memory
blah;blah;blah;
// error method
void addLL( LL *ll, void *p )
{
Node *newNode;
if( ( newNode = ( Node * )malloc( sizeof( Node ) ) ) == NULL )
return;
// error is right here, doesnt like putting the void pointer
// p into the char[100] of data
// says incompatible types in assignment
newNode->data = p;
newNode->next = NULL;
ll->tail->next = newNode;
ll->tail = newNode;
ll->size = (ll->size)+1;
return;
}
Everything else is correct, I've verified with others. However, I cant figure out why the void pointer conversion doesnt work. Ive tried casting as a char* and it doesnt work either and a few friends couldnt help me either. Any help is appreciated.