这句按F10和F11调试怎么动不了

wangdong20 2011-08-30 01:26:52
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
#include <string.h>


struct Date
{
int day;
int month;
int year;
};

struct Family
{
struct Date dob;
char name[20];
char father[20];
char mother[20];
struct Family *next;
struct Family *previous;
struct Family *p_to_pa; //Pointer to father structure
struct Family *p_to_ma; //Pointer to mother structure
};

struct Family *get_person(void)
{
struct Family *temp;
temp=(struct Family *)malloc(sizeof(struct Family));

printf("\nEnter the name of the person: ");
scanf("%s",temp->name);

printf("\nEnter %s's date of birth(day month year); ",temp->name);
scanf("%d %d %d",&temp->dob.day,&temp->dob.month,&temp->dob.year);

printf("\nWho is %s's father? ",temp->name);
scanf("%s",temp->father);

printf("\nWho is %s's mother? ",temp->name);
scanf("%s",temp->mother);

temp->next=temp->previous=NULL;
temp->p_to_pa=temp->p_to_ma=NULL;
return temp;
}
char set_ancestry(struct Family *pmember1,struct Family *pmember2)
{
if(strcmp(pmember1->father,pmember2->name)==0)
{
pmember1->p_to_pa=pmember2;
return 1;
}
if(strcmp(pmember1->mother,pmember2->name)==0)
{
pmember1->p_to_ma=pmember2;
return 1;
}
else
return 0;
}
//Fill in pointers for mother or father relationships
char related(struct Family *pmember1,struct Family *pmember2)
{
return set_ancestry(pmember1,pmember2)||
set_ancestry(pmember2,pmember1);
}


void main()
{
struct Family *first=NULL;
struct Family *current=NULL;
struct Family *last=NULL; //Pointer to previous person
char more='\0'; //Test value for ending input

for(;;)
{
printf("\nDo you want to enter the details of a%s person(Y or N)? ",
first!=NULL?"nother":"");
scanf(" %c",&more);

if(tolower(more)=='n')
break;

// current=get_person(); //这里按F11和F10都不能调试

if(first==NULL)
{
first=current;
last=current; //Remember for next iteration
}
else
{
last->next=current; //Set next address for previous Family
current->previous=last;
last=current; //Remember for next iteration
}
}

current=first;

while(current->next!=NULL) //Check for relation for each person in
{ //the list up to second to last
int parents=0; //Declare parent count local to this block
last=current->next; //Get the pointer to the next

while(last!=NULL) //This loop tests current person
{
if(related(current,last)) //Found a parent?
if(++parents==2) //Yes,update count and check it
break;

last=last->next; //Get the address of the next
}
current=current->next; //Next in the list to check
}

//Now tell them what we know
//Output family data in correct order
current=first;

while(current!=NULL)
{
printf("\n%s was born %d/%d/%d,and has %s and %s as parents.",
current->name,current->dob.day,current->dob.month,
current->dob.year,current->father,current->mother);
if(current->p_to_pa!=NULL)
printf("\n\t%s's birth date is %d/%d/%d ",
current->father,current->p_to_pa->dob.day,
current->p_to_pa->dob.month,
current->p_to_pa->dob.year);
if(current->p_to_ma!=NULL)
printf("\n\t%s's birth date is %d/%d/%d ",
current->mother,current->p_to_ma->dob.day,
current->p_to_ma->dob.month,
current->p_to_ma->dob.year);
current=current->next;
}

//Now free the memory
current=first;

while(current!=NULL)
{
last=current; //Save pointer to enable memory to be freed
current=current->next; //current points to next in list
free(last); //Free memory for last
}
}


以前写的函数还能用F11调试,但是这次这句就不行,还有我的编译器按F1不能用MSDN
希望大家帮我看看是编译器的问题,还是程序的问题。
...全文
542 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
仙度瑞城 2011-08-30
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 wangdong20 的回复:]
引用 1 楼 huayehanshan 的回复:
按F11不能调试,看看断点位置设的对不

按F1不能用MSDN,应该是你的编译器有问题,是不是没有安装MSDN。重新安装下看看

我没有设置断点,就是先按F10调试到这句再按F11箭头就动不了了
有时候按F11能进入函数内部,不过又要输入路径,好像调试就结束了,但这是个别情况
大部分情况是按F11箭头动不了了
[/Quote]
那你再这句打个断点...然后运行到这句的时候再按F11进入函数内部..
仙度瑞城 2011-08-30
  • 打赏
  • 举报
回复
尝试在程序其他地方打断点..看看程序有没有运行到这个语句..
wangdong20 2011-08-30
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 huayehanshan 的回复:]
按F11不能调试,看看断点位置设的对不

按F1不能用MSDN,应该是你的编译器有问题,是不是没有安装MSDN。重新安装下看看
[/Quote]
我没有设置断点,就是先按F10调试到这句再按F11箭头就动不了了
有时候按F11能进入函数内部,不过又要输入路径,好像调试就结束了,但这是个别情况
大部分情况是按F11箭头动不了了
坏男孩 2011-08-30
  • 打赏
  • 举报
回复
你可以先在main函数处设置一个断点,如果进去了就有可能是你的程序有死循环,没有进去就是你安装的编译器有问题。
jackyjkchen 2011-08-30
  • 打赏
  • 举报
回复
进帮助菜单,看能不能进MSDN
ningto.com 2011-08-30
  • 打赏
  • 举报
回复
在for循环外面设置一个, 然后看它进入for循环没有
叶落寒山 2011-08-30
  • 打赏
  • 举报
回复
按F11不能调试,看看断点位置设的对不

按F1不能用MSDN,应该是你的编译器有问题,是不是没有安装MSDN。重新安装下看看

69,336

社区成员

发帖
与我相关
我的任务
社区描述
C语言相关问题讨论
社区管理员
  • C语言
  • 花神庙码农
  • 架构师李肯
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧