美文网首页
1. 字符串 ngx_str_t

1. 字符串 ngx_str_t

作者: IN4 | 来源:发表于2017-11-17 11:24 被阅读0次

源码路径 : src/core/ngx_string.h

typedef struct {
    size_t      len;       //字符串的实际长度
    u_char     *data;      //字符串的值,不包含 c 字符串末尾的 \0
} ngx_str_t;

实例

 #include <stdio.h>
 #include <ngx_config.h>
 #include <ngx_core.h>
 #include <ngx_string.h>
 
 int
 main(int argc, char *argv[])
 {
     ngx_str_t t;
     char *str = "hello ngx";
     t.len = sizeof(str) - 1;
     t.data = (u_char *)str;
     
     printf("t.len = %lu\n", t.len);
     printf("t.data = %s\n", t.data);
     
     return 0;
 }

运行

gcc ./j_str.c 
      -I ../../objs/ 
      -I ../core/ 
      -I ../os/unix/ 
      -I /usr/local/opt/pcre/include 
      -o ./j_str
(说明:pcre路径为本机pcre具体路径) 

./j_str

结果

t.len = 9
t.data = hello ngx

相关文章

  • 1. 字符串 ngx_str_t

    源码路径 : src/core/ngx_string.h 实例 运行 结果

  • nginx常用的数据结构

    关于nginx的常用基本数据结构有: 字符串: ngx_str_t,使用nginx特有的字符串拷贝时,较少内存拷贝...

  • nginx第三天

    基本数据结构 之String ngx_str_t字符串结构data只想字符串数据的第一个字符,而不是有‘0’来表示...

  • 1. 字符串

    创建 简单操作 \ 转义符 + 拼接 * 复制 字符串 和 0 或者 负数相乘,会得到一个空字符串 进阶操作 Py...

  • Java_字符串

    1.知识点: 不可变字符串 可变字符串 2.知识点运用: 1.不可变字符串: 1.字符串* 1. 不可变的字符串 ...

  • 2019-04-23总结

    1.字符串 1.字符串1.count(字符串2) --》统计字符串中字符串出现的次数 2.字符串1.find(...

  • 1.字符串下标

    # 字符串下标[起始位置 : 终止位置 : 间隔 :] say = "0123456789" print(say[...

  • Python语言基础之——字符串和函数基础

    1.字符串相关方法 1.计算次数 1.count 字符串1.count(字符串2) - 统计字符串1中...

  • 5.bytes和bytearray

    目录1.字符串与字节2.bytes3.bytearray 1.字符串与字节 1.1 字符串与bytes 字符串是字...

  • iOS开发中字典和字符串的相互转换

    OC: 1.字符串转字典 2.字典转字符串 Swift 1.//将数组/字典 转化为字符串 2. //将字符串转化...

网友评论

      本文标题:1. 字符串 ngx_str_t

      本文链接:https://www.haomeiwen.com/subject/ryodvxtx.html