#include
int isValid(char *p)
{
if(*p <= '9' && *p >= '0') return 0;
while(*p)
{
if((*p >='A'&&*p<='Z')||(*p >='a'&&*p<='z')||(*p >='0'&&*p<='9')||*p=='_')
p++;
else return 0;
}
return 1;
}
int main ()
{
char *s[]={ "a%1","_a12","aaa","$ss","1sss"};
int total=sizeof(s)/sizeof(char *);
int i;
for(i = 0; i < total; i ++)
if(isValid(s[i])) printf("%s ", s[i]);
else s[i] = NULL;
printf("\n");
return 0;
}
FYI
void main()
{
char s[100];
int i=0,j;
printf("输入一个字符串:\n");
scanf("%s",s);
while(s[i]!='\0')
{
if(s[i]>='0'&&s[i]<='9'&&i!=0)//数字但不出现在第一个
{i++;continue;}
if(s[i]>='A'&&s[i]<='Z'||s[i]>='a'&&s[i]<='z'||s[i]=='_')
{i++;continue;}//英文字母和下划线
for(j=i;s[j]!='\0';j++)s[j]=s[j+1];//删除后需前移后面的字母
s[j]='\0';
}
printf("%s\n",s);
}