根据测试用例给出完整的c语言代码

【题目内容】
用指针来实现:将用户输入的由数字字符和非数字字符组成的字符串(字符个数不超过256个)中的数字提取出来,例如“msl123xyz456hkl789”,则提取的数字分别为123、456和789,将结果打印在屏幕上(要求每个数字一行)要求:使用指针相关知识来实现
【测试用例1】
输入:
hello123world456gg
输出:
123
456

遍历字符串,检测数字字符,转换为整数

#include <stdio.h>
int main()
{
    char s[300],*p = s;
    int count = 0;
    gets(s);
    while(1)
    {
        if(*p >='0' && *p <='9')
        {
            count++;
            printf("%c",*p);
        }
        else if(*p == '\0')
            break;
        else
        {
            if(count > 0)
                printf("\n");
            count=0;
        }
        p++;
    }
    return 0;
}