18 lines
650 B
C
18 lines
650 B
C
|
#include <stdio.h>
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
char *content = "disen:17791692095\njack:18799101234\nlucy:19088675432";
|
||
|
char phone[3][12];
|
||
|
// * 用来表示跳过内容
|
||
|
sscanf(content, "%*[^:]:%s%*[^:]:%s%*[^:]:%s", phone[0], phone[1], phone[2]);
|
||
|
// sscanf(content, "%*[^0-9]%[0-9]%*[^0-9]%[0-9]%*[^0-9]%[0-9]", phone[0], phone[1], phone[2]);
|
||
|
// sscanf(content, "%*[^0-9]%s%*[^0-9]%s%*[^0-9]%s", phone[0], phone[1], phone[2]);
|
||
|
// sscanf(content, "%*[a-z:\n]%s%*[a-z:\n]%s%*[a-z:\n]%s", phone[0], phone[1], phone[2]);
|
||
|
|
||
|
for (int i = 0; i < 3; i++)
|
||
|
printf("%s\n", phone[i]); // 循环打印
|
||
|
|
||
|
return 0;
|
||
|
}
|