qfedu-c-level/day12/d5.c

18 lines
474 B
C
Raw Permalink Normal View History

// sscanf() 高级用法: 跳过内容
#include <stdio.h>
#include <stdlib.h>
int main()
{
char *content = "disen,17791692095,610039018";
char first = 0;
char phone[12] = "";
char qq[12] = "";
sscanf(content, "%c", &first);
printf("%c\n", first);
// 跳过前6个字符然后读取11个字符放入 phone 中
sscanf(content, "%*6s%11s", phone);
printf("%s\n", phone);
sscanf(content, "%*18s%11s", qq);
printf("%s\n", qq);
}