How to call a function in another function for C++?
Hello everyone, I'm trying to call a function from another but I don't think i'm doing it correctly. Here is my code: int numOfNodes(struct listNode * firstNode){ int countNodes = 0; while(firstNode -> next != NULL){ countNodes ++; } return countNodes + 1; } int middleOfList(struct listNode * firstNode){ int count = 0; ** while(count != numOfNodes(struct listNode * firstNode) / 2) { ** if (count = (numOfNodes(struct listNode * firstNode)/2) - 1){ int previous = firstNode -> num; firstNode -> next; count++; } else{ firstNode -> next; count++; } } ** if(numOfNodes(struct listNode * firstNode) % 2 != 0) { return firstNode -> next -> num; } else { int total = ((firstNode -> next -> num) + previous) / 2 ; return total; } } I'm trying to call numOfNodes in middleOfList but keep getting the error: "error: expected primary-expression before 'struct'" The error occurs where you see ** in my middleOfList function. All answers are appreciated and thank you in advanced.