我们如何在C的sscanf中使用%n
下面是示例,但在numpassed中显示不正确的结果。
#include <stdio.h>
int main(void)
{
char str[] = "156987139xyz";
int conv1 = 0;
int conv2 = 0;
int conv3 = 0;
int numpassed = 0;
sscanf(str, "%2X %3X %3X %n", &conv1, &conv2, &conv3, &numpassed);
printf("conv1 = %X, conv2 = %X, conv3 = %X, numpassed = %i\n",
conv1, conv2, conv3, numpassed);
return 0;
}
这是我的结果 conv1 = 15,conv2 = 698,conv3 = 713,numpassed = 5
任何人都可以在这里帮助我