sscanf格式输出保留空格自定义留几个


//%[^&]
int main()
{
    char buf1[512] = {0};
    char buf2[512] = {0};

    sscanf("     123456 i mk dhhhd kkkk ","%[^\n]%s", buf1);
    sscanf("     123456 I mk dhhhd kkkk ","%*s%10[^&]%s", buf2);

    printf("%s\n", buf1);
    printf("%s\n", buf2);
    return 0;
}


输出:

    123456 i mk dhhhd kkkk 
 I mk dhhh

 

你可能感兴趣的:(c,c++)