当前位置:编程学习 > C/C++ >>

字符串格式化防止数组越界

char buffers[10];
   
    //_snprintf_s(buffers,sizeof(buffers),"%s","lsdafjasdlfjasdl;fjasdl;fjasd;fjasd;fjasd;fasd;fsd");
    _snprintf(buffers,sizeof(buffers),"%s","lseeeeeeeeeeeeeeeeeeeed");

    buffers[9] = 0;

    printf("%s",buffers);
    fflush(stdin);
 


摘自  C++ 技术中心 
补充:软件开发 , C++ ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,