解析一个字符串

sfa*_*tor 6 c string parsing

我有一个格式为"ABCDEFG,12:34:56:78:90:11"的字符串.我想将这两个用逗号分隔的值分成两个不同的字符串.我如何使用c语言在gcc中这样做.

Jer*_*fin 7

一种可能性是这样的:

char first[20], second[20];

scanf("%19[^,], %19[^\n]", first, second);
Run Code Online (Sandbox Code Playgroud)