这里是即时得到分段错误C语言,分段错误在哪里?
void searchcity()
{
struct city *ptr=citylist;
printf("Which city would you like me to search?: ");
scanf("%s",searchedcity);
// printf("%s",searchedcity);
while(ptr)
{
if(!strcmp(searchedcity,ptr->name))
printf("name= %s, statecode = %s,population = %s,region = %s,zipcode = %s\n",ptr->name,ptr->statecode,ptr->population,ptr->region,ptr->zipcode);
else
printf("sorry, couldnt find that city");
ptr=ptr->next;
}
}
不知道什么可以导致这种情况发生的功能。
可能有很多原因,但没有更多的代码很难说 –
这里没有足够的代码来调试这个。 – Yuushi
有没有什么可以导致它在函数中呢? – Alex