当前位置:网站首页>Assign a string pointer to an array [easy to understand]
Assign a string pointer to an array [easy to understand]
2022-07-28 21:33:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
such as char *p=”sdflkjasljfsjlsdfsa”; char p1[200]; take p Assign to p1 (1)strcpy(p1,p); (2)char *src=”helloworld”; char des[100]={0}; memcpy(des,src,strlen(src)+1); //void *memcpy(void *str1, const void *str2, size_t n) From the storage area str2 Copy n Characters to storage str1. (3) You can also use a cycle : for(int i=0;*(p+i)!=’\0’;i++) { p1[i]=*(p+i); } (4)sprintf(p1,”%s”,p);//p1 The length needs to be greater than p, Otherwise, overflow will occur C Library function – sprintf() http://www.runoob.com/cprogramming/c-function-sprintf.html linux c And snprintf() and sprintf() difference https://blog.csdn.net/u011068702/article/details/61916220
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/128891.html Link to the original text :https://javaforall.cn
边栏推荐
- MySQL
- 在子组件中使用el-date-picker报错
- 八、QOS队列调度与报文丢弃
- The general strike of three factories in St France may make the shortage of chips more serious!
- Bus, protocol, specification, interface, data acquisition and control system in industrial communication field
- SkiaSharp 之 WPF 自绘 拖曳小球(案例版)
- 百度搜索符合预期,但涉及外链黑帽策略,什么原因?
- LT7911D Type-C/DP转mipi 方案成熟可提供技术支持
- (PMIC) full and half bridge drive csd95481rwj PDF specification
- The 35 required questions in MySQL interview are illustrated, which is too easy to understand
猜你喜欢
CVPR 2022 | in depth study of batch normalized estimation offset in network
顶级“Redis 笔记”, 缓存雪崩 + 击穿 + 穿透 + 集群 + 分布式锁,NB 了
[cloud native] what is ci/cd| Ci/cd to smooth delivery obstacles
Timing analysis and constraints based on Xilinx
LeetCode·581.最短无序连续子数组·双指针
Meta opens the project aria pilot dataset and will develop real-time 3D maps in the future
Uniapp progress bar customization
Uncaught Error:Invalid geoJson format Cannot read property ‘length‘ of undefind
8、 QoS queue scheduling and message discarding
Quii Cordova plugin telerik imagepicker plug-in multi image upload out of sequence
随机推荐
The ref value ‘xxx‘ will likely have changed by the time this effect function runs.If this ref......
Another installation artifact
(PMIC) full and half bridge drive csd95481rwj PDF specification
Cloud security core technology
Icml2022 | timing self-monitoring video transformer
编码用这16个命名规则能让你少写一半以上的注释!
Api 接口优化的几个技巧
针对下一代Chromebook,联发科推出新款芯片组MT8192和MT8195
到底为什么不建议使用SELECT * ?
Summary of 29 typical problems in Devops planning and construction of securities enterprises based on containerized PAAS platform
What is the purpose of database read-write separation [easy to understand]
LT7911D Type-C/DP转mipi 方案成熟可提供技术支持
Study - 几何计算总结
Timing analysis and constraints based on Xilinx
八、QOS队列调度与报文丢弃
C # detailed steps for connecting to MySQL database
基于Xilinx的时序分析与约束
微服务架构下的系统集成
The greatest romance of programmers~
MySQL