我想提取字符串,並使用sscanf
一個字符串的整數Ç - sscanf的工作不
#include<stdio.h>
int main()
{
char Command[20] = "command:3";
char Keyword[20];
int Context;
sscanf(Command, "%s:%d", Keyword, &Context);
printf("Keyword:%s\n",Keyword);
printf("Context:%d",Context);
getch();
return 0;
}
但是這給了我輸出:
Keyword:command:3
Context:1971293397
我預計此輸出中:
Keyword:command
Context:3
爲什麼sscanf
的行爲也是這樣嗎?在此先感謝您的幫助!
有沒有很好的理由你不檢查'sscanf'的結果? –