我有这个:
#include<stdio.h>
#include<string.h>
int main(void)
{
int ret;
int major =0, minor= 0, build =0, revision =0;
char entry[16];
strcpy(entry,"1.2");
ret = sscanf(entry,"%d.%d.%d.%d", &major, &minor, &build, &revision);
printf("sscanf(""%s"") returned %d\r\n", entry, ret);
printf("major=%d, minor=%d, build=%d, revision=%d\r\n",
major, minor, build, revision);
return ret;
}
Aftersscanf
被调用,ret
是-1,但前两个条目被填充(主要是1,次要是2)。我原以为ret
是 2。我不知道出了什么问题。