I'm working on an assignment based on the Josephus problem and circular linked lists. The function below gives an error in Xcode (Control reaches end of non-void function) which I assume means that I need a return statement. However, when I add one, it doesn't accept it. But when I try the code in online compilers it works fine.
Node *newNode(int data)
{
Node *temp = new Node;
temp->next = temp;
temp->data = data;
}
You need to add return temp;
at the end:
Node *newNode(int data)
{
Node *temp = new Node;
temp->next = temp;
temp->data = data;
return temp;
}