惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

MyScale Blog
MyScale Blog
MongoDB | Blog
MongoDB | Blog
The Register - Security
The Register - Security
T
The Blog of Author Tim Ferriss
A
About on SuperTechFans
Vercel News
Vercel News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Jina AI
Jina AI
Stack Overflow Blog
Stack Overflow Blog
Cisco Talos Blog
Cisco Talos Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
W
WeLiveSecurity
S
Securelist
I
Intezer
F
Full Disclosure
WordPress大学
WordPress大学
腾讯CDC
酷 壳 – CoolShell
酷 壳 – CoolShell
Latest news
Latest news
aimingoo的专栏
aimingoo的专栏
C
Cisco Blogs
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
T
The Exploit Database - CXSecurity.com
P
Proofpoint News Feed
K
Kaspersky official blog
阮一峰的网络日志
阮一峰的网络日志
P
Proofpoint News Feed
J
Java Code Geeks
人人都是产品经理
人人都是产品经理
雷峰网
雷峰网
AWS News Blog
AWS News Blog
T
Tenable Blog
Google DeepMind News
Google DeepMind News
B
Blog RSS Feed
L
LINUX DO - 最新话题
小众软件
小众软件
T
Threat Research - Cisco Blogs
C
Cyber Attacks, Cyber Crime and Cyber Security
The GitHub Blog
The GitHub Blog
爱范儿
爱范儿
N
News and Events Feed by Topic
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
量子位
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Forbes - Security
Forbes - Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
U
Unit 42
O
OpenAI News
V
V2EX
T
Troy Hunt's Blog

Victrid's Personal Site

斯普拉遁3打工模式联机网络过程分析 DHCP无类型静态路由──一个摆设 配置透明代理,实现无感上网 Generating Unlimited Grammar: A Messenger Perspective LaTeX插入其他PDF中的矢量图 光速不变原理和迈克尔孙──莫雷实验 交大葡萄演义 调试微信内置浏览器 欧悌甫戎篇 苏格拉底的申辩篇 LCA 最近公共祖先 弥罗斯人的辩论 埃斯库罗斯作品:波斯人、阿伽门农 电路理论资料 Coronavirus: A Humanitarian Crisis 雨夜 linux配置SSR 二叉堆的实现 懒政 Placement New Flipped: A Love Story 我宁可呆在这样的疯人院里 谈新发本地病例 勇敢与智慧 Powerful but Limited Drafted VLC Libva Error Troubleshooting Ring-Fit新上手 政治艺术化与艺术政治化 动态规划——从分割等和子集入手 被背叛的革命 (1) Everything About DPT-RP1 When Using LINUX HTTP STATUS 451 二分法——重复情形 鸽巢排序与桶排序 为什么要写博客 系统更换 动窗法与前缀和——简单实践 非类型模板参数 判断的短路规则 CodeBlocks重装
C-Style String Operation
Victrid · 2019-10-29 · via Victrid's Personal Site

Here introduces C-style 'string' (mostly char[]) operation.

It's important that with classes and many more useful and Memory Safe functions, string shall not be processed with these functions.


  1. strcpy(dst,source),return dstcopy source to destination, returning the address of destination. be cautious that it can cause memory leak. example:

    char b[5]={0};

    char a[]="abcdefghijklmn";

    cout << (int)strcpy(b,a);you'll get an address.

    cout << ' ';

    for(int i = 0;i<=15;i++)cout<<b[i];

    returns:

    1
    2
    6422204          abcdefghijklmn#
    #:memory leak^
  2. strncpy(dst,src,n),return dstcopy n characters at most from source to destination. returning the address of destination. (better than strcpy to avoid memory leak.)

  3. strcat(dst,src),return dstadd src to the end of dst. Returning the address of dst.

  4. strncat(dst,src,n),return dst analogise with 2.

  5. strlen(s),return intlength of a string(to the \0, not the size of a list).

  6. strcmp(s1,s2),return intreturn (s1-s2).

  7. strncmp(s1,s2,n),return int,anal. with 2.

  8. strchr(s,ch),return addrreturn the address of the first ch in s.

    example:

    char a[]="abcdefghijklmn";

    cout<<strchr(a,'f'); returns: 6422278

    example:

    char a[]="abcdefghijklmn";

    cout<<(int)strchr(a,'q'); returns: 0

  9. strrchr(s,ch),return addrreturn the address of the last ch in s.

  10. strstr(s1,s2),return addranal with 7,but finding s2.

Author: Victrid

Permanent Link: https://victrid.dev/2019/c-style-string-operation/

License: Copyright (c) 2025 victrid Terms of Use

Ads by Google

Read our privacy policy on how these personalized advertisements are delivered to you.

For your reading experience, we provide full-text RSS feeds. Although math formulas cannot be displayed well, the interface can be adjusted as you like and there are no ads.