18 lines
474 B
C
18 lines
474 B
C
|
// 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);
|
|||
|
}
|