| 
              【示例程序】#include <stdio.h>
 
 void test(char *str)
 {
 int d, n, r;
 r = sscanf(str, "%d%n", &d, &n); // %n表示上一个操作所消耗的字符数
 printf("%s: 返回值=%d, 读取的值=%d, 读取的字符数=%d\n", str, r, d, n);
 }
 
 int main(void)
 {
 test("15");
 test("     38 27");
 test("简体中文");
 test("ABCDE");
 test("45.9");
 test("You are a dog.");
 test("");
 test(".");
 //test(NULL); // 程序出错
 return 0;
 }
 【运行结果】
 15: 返回值=1, 读取的值=15, 读取的字符数=2
 38 27: 返回值=1, 读取的值=38, 读取的字符数=7
 简体中文: 返回值=0, 读取的值=-858993460, 读取的字符数=-858993460
 ABCDE: 返回值=0, 读取的值=-858993460, 读取的字符数=-858993460
 45.9: 返回值=1, 读取的值=45, 读取的字符数=2
 You are a dog.: 返回值=0, 读取的值=-858993460, 读取的字符数=-858993460
 : 返回值=-1, 读取的值=-858993460, 读取的字符数=-858993460
 .: 返回值=0, 读取的值=-858993460, 读取的字符数=-858993460
 
 |