C语言统计字符串中的数字字符个数
#include <stdio.h>
int main() {
char str[80];
int count = 0;
printf('Enter a string:');
fgets(str, sizeof(str), stdin);
for (int i = 0; str[i] != '\0'; i++) {
if (str[i] >= '0' && str[i] <= '9') {
count++;
}
}
printf('count=%d', count);
return 0;
}
原文地址: https://www.cveoy.top/t/topic/phKH 著作权归作者所有。请勿转载和采集!