#include <stdio.h>
void main() {
int i = 0, number = 0;
char str[10];
printf("Please enter a string:");
while ((str[i] = getchar()) != '\n')
i++;
str[i] = '\0';
for (i = 0; str[i] != '\0'; i++)
if (str[i] >= '0' && str[i] <= '9')
number = number * 10 + str[i] - '0';
printf("digit=%d\n", number);
}
デジタル抽出:全ての数値文字を抽出する文字列(10文字未満)の終了を復帰フラグを入力し、それを10進数出力に変換します。
おすすめ
転載: blog.csdn.net/qq_38490457/article/details/104828778
おすすめ
ランキング