When I debug my program with lldb, I set a breakpoint in the main function, why did it end directly? In addition, the terminal should wait for my input ...
func.c
#include "func.h"
void insert_head(pnode *phead,pnode *ptail,int i){
pnode pnew = (pnode)calloc(1,sizeof(node));
pnew->num = i;
if(phead == NULL){
*phead = pnew;
*ptail = pnew;
}else{
pnew->pnext = *phead;
*phead = pnew;
}
}
void print_list(pnode phead){
while(phead){
printf("%d",phead->num);
phead=phead->pnext;
}
}
main.cpp
#include "func.h"
int main()
{
pnode phead,ptail;//create new head ptial point to sturct
phead = ptail = NULL;
int i;
while(scanf("%d",&i) != EOF){
insert_head(&phead,&ptail,i);
}
print_list(phead);
return 0;
}
func.h
#pragma once
#include <cstdio>
#include <cstdlib>
//定义结构体
typedef struct Node{
int num;
struct Node *pnext;
}node,*pnode;
//头插法
void insert_head(pnode *phead,pnode *ptail,int i);
void print_list(pnode phead);
You can see the image , i want to figure out this,pls help me , thanks guys