当前位置:网站首页 > 技术博客 > 正文

malloc 库文件



strncpy 没有自动加上终止符的,需要手动加上不然会出问题的。

/* strncpy 实例 */ #include <stdio.h> #include <string.h> int main () { char str1[]= "To be or not to be"; char str2[40]; char str3[40]; /* 拷贝到缓冲区: */ strncpy ( str2, str1, sizeof(str2) ); /* 拷贝 5 个字符: */ strncpy ( str3, str2, 5 ); str3[5] = '0'; /* 手动加上终止符 */ puts (str1); puts (str2); puts (str3); return 0; }

版权声明


相关文章:

  • mysql8.0.23安装配置教程2024-11-15 20:30:02
  • 交叉验证的作用2024-11-15 20:30:02
  • 适配器模式的实现原理2024-11-15 20:30:02
  • java工具类库2024-11-15 20:30:02
  • 爬虫软件叫什么2024-11-15 20:30:02
  • pwn是什么意思2024-11-15 20:30:02
  • c语言编程题经典100例2024-11-15 20:30:02
  • juc并发编程2024-11-15 20:30:02
  • 数组指针和指针数组的定义2024-11-15 20:30:02
  • java单元测试是什么2024-11-15 20:30:02