C言語についての質問です。
今勉強している内容で、参考書の通り入力してもうまくいきません。
数字文字の出現回数を数えるプログラムなのですが、実行結果に数が反映されません。
何が原因がわかる方がいらっしゃればご教授願いたいです。
--以下、実際のプログラム-------------
#include<stdio.h>
void str_dcount(const char str[], int cnt[]){
unsigned i = 0;
while (str[i]){
if (str[i] >= '0'&&str[i] <= '9')
cnt[str[i] - '0']++;
i++;
}
}
int main(void){
int i;
int dcnt[10] = { 0 };
char str[100];
printf(">>");
scanf_s("%s", str);
str_dcount(str, dcnt);
printf(">>>>>\n");
for (i = 0; i < 10; i++)
printf("'%d':%d\n", i, dcnt[i]);
return(0);
}
*添付画像は参考書の内容の写真です