首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

为何用这个表达式提取不出来数字

2012-09-24 
为什么用这个表达式提取不出来数字?想把1234提取到b#include stdio.h#include string.hmain(){char b[

为什么用这个表达式提取不出来数字?
想把1234提取到b
#include <stdio.h>
#include <string.h>
main()
{
  char b[5];
  sscanf("we1234","%[1-9]", b);
  printf("%s",b);
  getchar();
  }

[解决办法]

探讨
用这个:
sscanf("we1234","%*[a-z]%[1-9]",b);

[解决办法]
探讨
C/C++ code
#include <stdio.h>
#include <string.h>
int main()
{
char b[5];
sscanf("we1234", "%*[^1-9]%[1-9]", b);
printf("%s", b);
getchar();
return 0;
}

热点排行