Hacker_DL 2022-02-22 23:26 采纳率: 16.7%
浏览 57
已结题

请教各位 CLion 编写C 在数据组传递后 在断点调试中无法在debug窗口中看到数组中的值

谢谢各位,请允许我用一个题目说明这个问题

题目内容如下:
1重复数字检查
题目内容:从键盘输入一个数,检查这个数中是否有重复出现的数字。如果这个数中有重复出现的数字,则显示“Repeated digit!”;否则显示“No repeated digit!”。
已知函数原型:int CountRepeatNum(int count[], int n);
若有重复数字,则该函数返回重复出现的数字;否则返回-1.

程序运行结果示例1:
Input n:
28212↙
Repeated digit!

程序运行结果示例2:
Input n:
12345↙
No repeated digit!

输入提示:"Input n:\n"
输入格式: "%ld"
输出格式:
有重复数字,输出信息: "Repeated digit!\n"
没有重复数字,输出信息: "No repeated digit!\n"

我的C语言代码:

#include <stdio.h>

int CountRepeatNum(int count[], int n) {
    while (n > 0) {
        ++count[n % 10];
        n /= 10;
    }

    for (int i = 0; i < 10; ++i) {
        if (count[i] >= 2) {
            return i+1;
        }
    }

    return -1;
}

int main() {
    setbuf(stdout, NULL);

    int n;
    int count_arr[10] = {0};

    printf("Input n:\n");
    scanf("%d", &n);

    if (CountRepeatNum(count_arr, n) != -1) {
        printf("Repeated digit!\n");
    } else {
        printf("No repeated digit!\n");
    }

    return 0;
}

CLion不显示数组的值(问题截图)

img

img


我这个问题只出在数组以函数参数传递的问题中。如果在主函数中使用函数,debug窗口能显示所有数组中的元素。就像下面这样:

img

img

我想要的就是是否可以通过什么方式,让我在函数调用的时候,也能够在debug窗口里看到完整的数组内容情况?

  • 写回答

1条回答 默认 最新

  • _GX_ 2022-02-22 23:47
    关注

    In Evaluate / Watches window use the following expression:

    (int [10])*count
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 3月13日
  • 已采纳回答 3月13日
  • 修改了问题 2月22日
  • 创建了问题 2月22日

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测