sscanf基本用法

来源:互联网 发布:hexo 知乎 编辑:程序博客网 时间:2024/05/22 04:23

sscanf()函数也很熟悉,但是sscanf()也用的很少,但是它依然很强大,具体用法以后再去研究,下面先叙述一点简单的用法.

#include <iostream>#include <cstdio>using namespace std;const int maxn=0;int main(){    char str[100];    sscanf("123qwq","%*d%s",str);    printf("%s\n",str);//qwq    sscanf("123qwq456","%[0-9]",str);    printf("%s\n",str);//123    sscanf("123qwq456","%[0-9]",str);    printf("%s\n",str);//123    int x;    sscanf("1234","%d",&x);    printf("%d\n",x);    return 0;}


0 0