字符串转数字
C语言怎么吧字符串 [123,456]中的字符123和456转化成数字123和456?
#include <stdio.h>
main()
{
char s[]="123,456";
char *p=s;
int a, n;
while (*p)
{
if (sscanf(p,"%d%n",&a,&n) == 1)
{
printf("%d\n", a);
p += n;
}
else
++p;
}
}