打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
sprintf格式化复制函数小程序
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(void)
{
    char *p = "%host=3&ip=192.168.1.1&test";
    char buff[128];
    char *match;

    match = strstr(buff,"dir=");
    if(match==0) printf("no match\n");
    else {
        printf("match:\n");
        printf("%s\n",match);
        sscanf(match,"dir=%s",buff);//遇到换行符结束,而并非直到字符串结尾
        sprintf(buff1,"->%s<-",match);//只是复制而已,并加上需要格式化的修饰字符
    }
    printf("buff:\n");
    printf("%s\n",buff);
    printf("buff1:\n");
    printf("%s\n",buff1);

    return 0;

}

运行结果:

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
printf,sprintf,vsprintf
sprintf %02x
C/C 字符串和数字互换方案收集(转)
Linux下c基于openssl生成MD5的函数
C语言sprintf()函数:将格式化的数据写入字符串
sprintf的使用
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服