代码示例:#includestdio.h#includestring.h#include "ctype.h"int main(){char str[100] = "", s[100] = "";int i = 0, j = 0;gets_s(str,sizeof(str)); while (str[i] != '\0'){if (isdigit(str[i])) {s[j]=str[i];j++;}i++;}puts(s);return 0;}