📜  使用 strtok 解析 - C 编程语言代码示例

📅  最后修改于: 2022-03-11 15:04:38.759000             🧑  作者: Mango

代码示例1
// A C/C++ program for splitting a string
// using strtok()
#include 
#include 
 
int main()
{
    char str[] = "Geeks-for-Geeks";
 
    // Returns first token
    char* token = strtok(str, "-");
 
    // Keep printing tokens while one of the
    // delimiters present in str[].
    while (token != NULL) {
        printf("%s\n", token);
        token = strtok(NULL, "-");
    }
 
    return 0;
}