scanf9.c

来自「绝对正真的stdio.h的实现」· C语言 代码 · 共 31 行

C
31
字号
#include <stdio.h>#include <stdlib.h>#include <string.h>intmain (void){  int matches;  char str[10];  str[0] = '\0';  matches = -9;  matches = sscanf ("x ]", "%[^] ]", str);  printf ("Matches = %d, string str = \"%s\".\n", matches, str);  printf ("str should be \"x\".\n");  if (strcmp (str, "x"))    abort ();  str[0] = '\0';  matches = -9;  matches = sscanf (" ] x", "%[] ]", str);  printf ("Matches = %d, string str = \"%s\".\n", matches, str);  printf ("str should be \" ] \".\n");  if (strcmp (str, " ] "))    abort ();  return 0;}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?