qfedu-c-level/day12/d5.c

18 lines
474 B
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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);
}