当前位置:网站首页>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
边栏推荐
- The greatest romance of programmers~
- How Oracle exports data (how Oracle backs up databases)
- How NPM switches Taobao source images
- Buuctf questions upload labs record pass-11~pass-20
- 瑞典法院取消对华为和中兴的5G频谱拍卖禁令
- ABB electromagnetic flowmeter maintenance signal transmitter maintenance 41f/e4 technical parameters
- Kubeadm搭建kubernetes集群
- ICML2022 | 时序自监督视频transformer
- Pytorch学习记录(三):随机梯度下降、神经网络与全连接
- Source insight uses shortcut keys
猜你喜欢
![Leetcode interview question 02.07. Linked list intersection [knowledge points: Double pointers, stack]](/img/51/ec623bb609f5f57150e7244cf5f9b7.png)
Leetcode interview question 02.07. Linked list intersection [knowledge points: Double pointers, stack]

物联网技术栈之网关技术

Analysis of critical path

Buuctf questions upload labs record pass-11~pass-20

There have been two safety accidents in a month after listing. Is L9 ideal?

Uncaught Error:Invalid geoJson format Cannot read property ‘length‘ of undefind

职场高薪 |「中高级测试」面试题

Adventures of little mouse: behind the scenes gags of moss 2

CVPR 2022 | 网络中批处理归一化估计偏移的深入研究

4.2 Virtual Member Functions
随机推荐
Learning typescript (II)
Ijcai2022 tutorial | dialogue recommendation system
The 35 required questions in MySQL interview are illustrated, which is too easy to understand
Paging function (board)
酷派主动终止针对小米公司的专利侵权诉讼
属性基加密仿真及代码实现(CP-ABE)论文:Ciphertext-Policy Attribute-Based Encryption
聊一聊数据库的行存与列存
Quii Cordova plugin telerik imagepicker plug-in multi image upload out of sequence
SkiaSharp 之 WPF 自绘 拖曳小球(案例版)
Talk about row storage and column storage of database
详细讲解C语言12(C语言系列)
Maxwell 一款简单易上手的实时抓取Mysql数据的软件
8、 QoS queue scheduling and message discarding
在子组件中使用el-date-picker报错
Go concurrent programming basics
职场高薪 |「中高级测试」面试题
MSI Bao'an factory is on fire! Official response: no one was injured, and the production line will not be affected!
Capture video by buffering
30.学习Highcharts 标签旋转柱形图
Redis缓存雪崩、缓存穿透、缓存击穿