代码如下
#include<stdio.h>
#include<string.h>
int main(int argc, char const *argv[])
{
char buf[128] = {0};
int m1 = 0, m2 = 0;
int s1 = 0, s2 = 0;
char lrc[128] = "";
sscanf("[02:16.33][04:11.44]我想大声宣布对你恋恋不舍","[%*1d%d",&m1);
sscanf("[02:16.33][04:11.44]我想大声宣布对你恋恋不舍","[%*d%*[^4]%d",&m2);
sscanf("[02:16.33][04:11.44]我想大声宣布对你恋恋不舍","%*[^:]%*c%2d",&s1);
sscanf("[02:16.33][04:11.44]我想大声宣布对你恋恋不舍","%*[^:]%*c%*[^:]%*c%2d",&s2);
sscanf("[02:16.33][04:11.44]我想大声宣布对你恋恋不舍","%*20s%s",lrc);
printf("%d秒打印歌词%s\n",m1*60+s1,lrc);
printf("%d秒打印歌词%s\n",m2*60+s2,lrc);
return 0;
}
运行结果如下