sscanf 格式化给变量赋值

    char cBuff[100] = "0,1,1.1,2.2,3.3,444444!@#¥%……";

    int i1, i2;
    float f1, f2, f3;
    sscanf(cBuff, "%d,%d,%f,%f,%f", &i1, &i2, &f1, &f2, &f3);

    CString strMsg;
    strMsg.Format(_T("%d     %d    %02f   %f    %f"), i1, i2, f1, f2, f3);
    AfxMessageBox(strMsg);//0    1   1.100000    2.200000    3.300000

以逗号隔开,后面的可以作废

posted @ 2022-02-10 17:59  ckrgd  阅读(85)  评论(0编辑  收藏  举报