this is the structure of my node
typedef struct Node{
int x;
Node* Next;
};
// in main() i can make the head pointer,and assign it to NULL i-e
Node* start_pointer=NULL; //this line is in my main() function
// and i consider it head pointer
void add_node(Node* start_pointer){
Node first;
cout<<"Enter the value of X\n ";
cin>>first.x;
if (start_pointer==NULL){
start_pointer=&first; //try to assign an address of object of its pointer
first.Next=NULL;
}
else {
Node* temp=start_pointer;
while (temp->Next != NULL){ //program is break at this stage
temp=temp->Next;}
temp->Next=first.Next;
first.Next=NULL;
}
我正在为节点 * 分配一个地址并尝试使用 '->' 运算符来捕获它,可以吗?每次我运行 add_node 函数时它都会执行但不幸的是它没有进入其他条件