0
点赞
收藏
分享

微信扫一扫

深入理解 Nginx Concat 模块:示例、安装和使用方法

海牙秋天 2024-05-28 阅读 3

整理思维导图

定义自己的命名空间my_sapce,在my_sapce中定义string类型的变量s1,再定义一个函数完成对字符串的逆置。

#include <iostream>
#include <cstring>

using namespace std;
namespace my_space
{
    string s1;
}

void show()
{
    cout<<"hello"<<endl;
}
void re(char *p)
{
    if(NULL == p){
        return ;
    }
    //abcde
    char *head = p;
    char *tail = p+strlen(p)-1;
    char temp;

    while(head < tail){
        temp = *head;
        *head = *tail;
        *tail = temp;
        head++;
        tail--;
    }
}

int main()
{
    cout<< "请输入字符串:" <<endl;
    cin >> my_space::s1;
    char buf[100];
    strcpy(buf,my_space::s1.data());

    re(buf);
    cout<< buf<< endl;

    return 0;
}

举报

相关推荐

0 条评论