patest吧 关注:1,484贴子:1,702
  • 12回复贴,共1

问一下调试的时候出现“无可用源”该怎么办?

只看楼主收藏回复

大概就这样:
附一部分代码,是在用qsort方法的comp函数要跳出的时候总是出现的问题。
之前是 未加载urctbased.pdb 有资料显示反汇编看看错误,没有学过汇编所以看不懂反汇编。网上用的能看懂的方法试过了但是好像没用。


IP属地:海南1楼2017-02-17 15:27回复
    问题应该不是你描述的那样
    1. 为啥用中文命名文件?
    2. 把代码贴出来看看,错误信息贴出来看看
    3. qsort()是c的,sort()才是cpp的,两者的原型也不一样
    4. qsort()里面
    struct person pa = *(struct person *)a;
    估计是你抄错了,至少也应该是
    struct person *pa = (struct person *)a
    后面也把 . 换成 ->
    5. 其他的先把代码和错误信息贴出来再看


    IP属地:浙江2楼2017-02-17 15:57
    收起回复
      2026-02-22 23:03:08
      广告
      不感兴趣
      开通SVIP免广告
      C.人口普查
      #include<stdio.h>
      #include<stdlib.h>struct person {
      char name[5];
      int year, month, day;
      int flag;
      }People[10000];
      int comp(const void *a, const void *b) {
      struct person *pa = (struct person *) a;
      struct person *pb = (struct person *) b;
      if (pa->year != pb->year)
      return pa->year - pb->year;
      else if (pa->month != pb->month)
      return pa->month - pb->month;
      else
      return pa->day - pa->day;
      }
      int main()
      {
      int count = 0, N, i; scanf("%d", &N);
      for (i = 0; i < N; i++) {
      scanf("%s %d/%d/%d", People[i].name, &People[i].year, &People[i].month, &People[i].day);
      if (People[i].year < 2014 && People[i].year > 1814) {
      People[i].flag = 1;
      count++;
      }
      else if (People[i].year == 2014) {
      if (People[i].month < 9) {
      People[i].flag = 1;
      count++;
      }
      else if (People[i].month == 9) {
      if (People[i].day <= 6) {
      People[i].flag = 1;
      count++;
      }
      else
      People[i].flag = 0;
      }
      else
      People[i].flag = 0; }
      else if (People[i].year == 1814) {
      if (People[i].month > 9) {
      People[i].flag = 1;
      count++;
      }
      else if (People[i].month == 9) {
      if (People[i].day >= 6) {
      People[i].flag = 1;
      count++;
      }
      else
      People[i].flag = 0;
      }
      else
      People[i].flag = 0;
      }
      else
      People[i].flag = 0;
      }
      qsort(People, N, sizeof(struct person), comp);
      i = 0;
      printf("%d ", count);
      while (People[i].flag == 0)
      i++;
      printf("%s %s", People[i].name, People[i + count - 1].name); return 0;
      }


      IP属地:海南3楼2017-02-17 18:34
      收起回复