• ADADADADAD

    C语言中如何让输入的数字隐藏[ 编程知识 ]

    编程知识 时间:2024-12-03 17:07:05

    作者:文/会员上传

    简介:

    在C语言中,可以使用密码输入的方式来隐藏输入的数字。下面是一个示例代码:#include <stdio.h>#include <conio.h>int main() {char password[20];int num;printf("Enter a num

    以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。

    在C语言中,可以使用密码输入的方式来隐藏输入的数字。下面是一个示例代码:

    #include <stdio.h>#include <conio.h>int main() {char password[20];int num;printf("Enter a number: ");scanf("%d", &num);printf("Enter password to hide the number: ");int i = 0;while (1) {password[i] = getch();if (password[i] == 13) {break;} else {printf("*");}i++;}password[i] = '\0'; // null-terminate the passwordprintf("\nHidden number: %d\n", num);return 0;}

    在这个示例代码中,用户首先输入一个数字,然后输入一个密码来隐藏这个数字。当用户输入密码时,数字将被隐藏,只有*字符显示出来。

    C语言中如何让输入的数字隐藏.docx

    将本文的Word文档下载到电脑

    推荐度:

    下载
    热门标签: c语言