c语言中反转字符串的函数strrev(), reverse()
2024-08-26 06:39:39
1.使用string.h中的strrev函数
#include<stdio.h>
#include<string.h>
int main()
{
char s[]="hello";
strrev(s);
puts(s);
return ;
}
2.使用algorithm中的reverse函数
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main()
{
string s= "hello";
reverse(s.begin(),s.end());
cout<<s<<endl;
return ;
}
这两个函数在我测试的时候出现了两种完全不同的情况
1.strrev函数只对字符数组有效,对string类型是无效的。
2.reverse函数是反转容器中的内容,对字符数组无效。
最新文章
- Java 8 的 Nashorn 脚本引擎教程
- OpenCV配置经历简述
- 前端---DOM
- java多线程的几种实现方式记录
- android Activity类中的finish()、onDestory()和System.exit(0) 三者的区别
- 【BZOJ-2502】清理雪道 有上下界的网络流(有下界的最小流)
- hdu 1845
- Codeforce727B --- Bill Total Value(字符串处理 正则表达式)
- 使用node.js抓取有路网图书信息(原创)
- Python问题之奇怪诡异的Bug
- DJANGO,获取当前用户名,用户组名,用户组权限
- 一年四个P(Project)
- AES SHA-1 SM3 MD5
- JPA 批注参考
- Simple tutorial for using TensorFlow to compute a linear regression
- numpy库补充 mean函数应用
- 七月在线爬虫班学习笔记(二)——Python基本语法及面向对象
- Centos下内网DNS主从环境部署记录
- 如何判断mac地址时multicast还是broadcast ?
- 使用Thrift让Python为Java提供服务
热门文章
- 单源最短路dijkstra算法&;&;优化史
- TeamViewer13个人版使用中提示为商用版导致无法使用
- 15-oauth2+oidc实现Server部分
- java生成PDF,并下载到本地
- 优步UBER司机全国各地奖励政策汇总 (2月22日-2月28日)
- c++继承详解:共有(public)继承,私有继承(private)继承,保护(protected)继承
- mysql题目练习的答案
- Unbuntu安装RVM
- ShimmerTextView
- libevent学习八(evbuffer)