This is just a curiosity thing, but I have the following code. I'm adding elements to a linked list recursively. This code works perfectly fine.
But when I remove the return statement from the insert function, it does not throw an error. The program compiles and when I run it I get a "Segmentation Fault".
I find this strange. Shouldn't a missing return statement produce an error?
Just wondering why it wouldn't:
Node* insert(Node* node, int values[]) {
for (int i=0; i < 9; i++) {
insertRecursively(node, values[i]);
}
return node;
}
int main() {
int a[] = {1,2,3,4,5,6,7,8,9};
node = insert(node, a);
print(node);
return 0;
}