第二个C语言代码

有问题,还没找出哪里出错了

输入一串字符,问号结束
统计1~9各出现的次数

***************************************************************************************
 
#include<stdio.h>
void main()
{
    char *ps,s;
    int i,n,m;
    char str[1000];
    printf("请输入字符串(以问号结尾) ");
    //gets(str);

    scanf("%s",&str);
   
for(m=0;m<=9;m++)
{
    s=m;
    ps=str;
        for (i=0;*ps!=' ';i++)
            {
                ps=str+i;
                for(n=0;*ps==s && *ps!='?';)
                    n++;
            printf("字符串中%d",m);
            printf("的个数是%d ",n);
            }
}
}

****************************************************************************************


#include<stdio.h>
void main()
{
    char *ps,s;
    int i,n,m;
    char str[1000];
    printf("请输入字符串(以问号结尾) ");
    //gets(str);

    scanf("%s",&str);
   
for(m=0;m<=9;m++)
{
    s=m;
    ps=str;
    for(n=0;*ps==s && *ps!='?';n++)
    {
        for (i=0;*ps!=' ';i++)
            ps=str+i;
    }
    printf("字符串中%d",m);
    printf("的个数是%d ",n);
}
}