|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<stdio.h>
int main()
{
int i = 0,j;
int str[80];
int a[80];
printf("Enter a str:");
do
{
scanf("%c",&str[i]);
i++;
}while(str[i - 1] != '#');
str[i] = '\0';
getchar();
i = 0;
j = 0;
while(str[i] != '\0')
{
if((str[i] >= '0'&&str[i] <= '9') || (str[i] >= 'A'&&str[i] <= 'F')||(str[i] >= 'a'&&str[i] <= 'f'))
{
a[j] = str[i];
j++;
}
i++;
}
a[j] = '\0';
printf("NEW string = ");
for(i = 0; i != '\0'; i++)
{
printf("a[%d] = %c",i,a[i]);
}
}
上面这段代码我想输入一段字符串,然后过滤出0 - 9,a - f,A - F,把他们赋给另外一个数组,哪里出错了,为什么成功不了?
感谢! |
|