I've been struggling trying to figure out why I am getting the following warning:
initialization makes pointer from integer without a cast
The highlighted warnings are where I mentioned below. The code I am currently using is just the beginning of creating tree of elements in a linked list fashion. This code seems to be working fine however I get docked points for warnings.
typedef struct Node {
struct Node *leftChild;
struct Node *rightChild;
char data;
} Node;
Node *TreeCreate(int level, const char *data) {
struct Node *ptr = (struct Node*) malloc(sizeof (Node));
if (ptr == NULL) {
// malloc failed
return 0;
}
ptr->data = data; // WARNING
ptr->leftChild = NULL;
ptr->rightChild = NULL;
return ptr;
}
// TEST CODE IN MAIN
char list[6] = {'A', 'B', 'C','\0'};
// Determines the element
const char *tree = list[0]; // WARNING
ptr = TreeCreate(1, tree);
if (ptr != NULL) {
sprintf(string, "TreeData: %c\n", ptr->data);
OledDrawString(string);
OledUpdate();
}