It works in the Windows Command Prompt like I haven't missed the return new_node;
#include <stdio.h>
#include <stdlib.h>
typedef struct Node {
int value;
struct Node *next;
} Node;
Node* create_node(int value) {
Node *new_node = (Node *) malloc(sizeof(Node));
if (new_node == NULL) return NULL;
new_node->value = value;
new_node->next = NULL;
// no return statement
}
int main(int argc, char *argv[]) {
Node *head = NULL;
// no errors here, head just receives the right pointer
head = create_node(5);
return 0;
}
So the function create_node(int)
returns pointer anyway. How does it work?
Compiled with gcc (x86_64-posix-seh-rev1, Built by MinGW-W64 project) 7.2.0